Maybe I'm showing my age now and things are not done as they used to be done before, but I'm used to the fact that you free() or delete some memory and the memory is returned to the heap for the process, and not to the system. Only when the amout of free memory hit a predefined figure was the memory actually freed to the system, to prevent memory fragmentation. This was when the C compiler ran from a floppy disk however
jbenoit: "eventually" will not stop you from allocating further memory. The reserved memory will be used before more is requested from the system. I doesn't hold on to memory knowing you want it for something else.
As for vacuum processes, all you have to do is a loop allocating 100KB at a time until malloc() returns NULL. At that point you have allocated all that is possible from a single process (which depends on page file size, OS, 32/64bit etc). Or you can buy a product that does this for you for between $20 and $99 or so. It'll come with a flashy GUI and lots of flashing lights, but behind the scenes, it does exactly the same as you can do in 5 minutes by writing it yourself.
Defragmenting virtual memory is a nonsense idea anyway, even if you have a 4GB contiguous chunk of memory, theres nothing stopping the OS mapping those contiguous chunks to a random chunks of physical memory. The only way of getting a chunk of contiguous physical memory is by dropping to the device driver ring (ring 0) and requesting it there.
Bookmarks