I try to allocate as much as possible physical RAM on 2 GB notebook.
1. Determine how much memory can I use.
mem_size = phys_mem_size - commited bytes ("Commited Bytes" of "Memory" object - performance counter)
2. Call SetProcessWorkingSetSize() with original limits increased by mem_size.
3. Call VirtualAlloc() with "commit" flag starting from mem_size.
After some iterations (decreasing size) function succeeds.
4. Call VirtualLock() to force pages being in RAM. It succeeds also.
5. Call VirtualUnlock()
6. Call VirtualFree()
7. Call SetProcessWorkingSetSize() with original limits.
8. SetProcessWorkingSetSize() again and this time it fails.
Let's say that when called for the first time it succeeded for 700 MB, but for the second time succeeded for 70 MB. Why ?
Unterforunately I do not have acceess to this laptop (it is over the ocean) so I cannot debug it.
I never noticed such problem eralier on 512 MB PC (W2K) nor my current 256 MB PC (XP).