If I need a program to r/w data larger then 1T randomly, a simplest way is putting all data into memory. For the PC with 2G memory, we can nevertheless work by doing a lot of i/o. Different computers have different size memory, so how to alloc suitable memory on computers from 2G to 2T memory in one program?
I thought of popen /proc/meminfo
and alloc MemFree
but I think it maybe have a better way.
note:
- use Linux, but other OS is welcome
- avoid being OOM killed as well as possible (without root)
- disk i/o as less as possible
- use multiprocessing
- c or c++ answer is fine