0

I have a hard work to make a existing x64 software into x86 version.

It will cost about 6G~10G memory in x64, but it crashes in running x86 version when it costs about 1.5G memory.

I'm wondering whether there's an easy way to make cache file/temp file to do some memory<->hard disk exchange without much code changes?

Thank you

bychance
  • 282
  • 4
  • 14
  • There's no memory leak here. "Crash" means out of memory. 6G~10G is normal. I have a vector of a custom data structure. There're many O(N^2) work to do with this vector. I have to "cache" each single element just like memory page management in OS. – bychance Jan 21 '13 at 06:24

1 Answers1

0

If it crashes, you've got a bug (or a few) to fix.

Whether or not you can make your code work in 32-bit mode with up to 2-3G RAM max depends a lot on the code. And you probably are much better equipped to answer this question since you've got your code and we don't have a slightest clue about what it's supposed to do and how it works.

A few ideas:

  1. fix memory leaks
  2. fix memory fragmentation
  3. process data in smaller and/or fewer chunks
  4. reorder processing into independent stages each of which uses less memory
  5. share memory between the various processing stages whenever possible (think of C/C++ union), minimize unused space and unnecessary data copies
  6. use smarter algorithms requiring less memory
  7. compress and decompress data, possibly on the fly
  8. split the whole program into a few to take advantage of the bigger cumulative address space and more physical memory than 4G with PAE
  9. if it's C++, you could try "expanding" the virtual address space and the amount of available memory by overloading new/delete, []/*/-> and managing memory to/from disk I/O sort of behind the scenes. You may use memory mapped files or ordinary files. This may turn ugly and hard to do correctly and fast.
  10. find or implement a virtualization solution that can run your 64-bit app in a 32-bit OS or in a 64-bit VM running on top of or in parallel with your 32-bit OS. You may not like the speed or the hurdles, though.
  11. ...

Good luck!

Alexey Frunze
  • 61,140
  • 12
  • 83
  • 180
  • Comment is added in the first post to make question more clearer. And I'm looking for a framework or something similar which needs few changes in codes. – bychance Jan 21 '13 at 06:28
  • e.g. A container looks like STL vector, but it can handle file cache in the background and we can replace STL vector with the "miracle" vector with small code changes :) – bychance Jan 21 '13 at 07:32
  • If that's really all you need, go for it. – Alexey Frunze Jan 21 '13 at 07:34