VIRT, RES question

I have code that uses large portions of memory >2GB on a 4GB 32-bit system. I am watching the memory usage with top -p while my code runs. As the code executes, it stores data in memory which is dynamically allocated with new. The data is dumped to file, and I use delete to free up memory so I can store another large amount with new.

My question is this: why do I not see a change in VIRT and RES when I use delete to free memory. I see the memory increase as the code goes through the "new" section the first time, but not subsequent times (which I assume happens because it is actually using less memory than the max amount which displayed in VIRT and RES)
That's the standard behavior. When you use delete, memory pages that become free as a result are not given back to the OS, but kept around for future use.
It's different with new[] and delete[] - delete[] really frees the memory.
Topic archived. No new replies allowed.