C++ – Staying away from virtual memory in Windows\C++

cmemoryswapwinapiwindows

I'm writing a performance critical application where its essential to store as much data as possible in the physical memory before dumping to disc.

I can use ::GlobalMemoryStatusEx(...) and ::GetProcessMemoryInfo(...) to find out what percentage of physical memory is reserved\free and how much memory my current process handles.
Using this data I can make sure to dump when ~90% of the physical memory is in use or ~90 of the maximum of 2GB per application limit is hit.

However, I would like a method for simply recieving how many bytes are actually left before the system will start using the virtual memory, especially as the application will be compiled for both 32bit and 64bit, whereas the 2 GB limit doesnt exist.

Best Answer

How about this function:

int
bytesLeftUntilVMUsed() {
    return 0;
}

it should give the correct result in nearly all cases I think ;)