On Jun 2, 7:12*pm, Hong Chen <HongChe...@gmail.comwrote:
I developed a large program and found the program does not really
release memory after the delete operation is taken, since, according
to "performance monitor", the virtual bytes used by this process does
not decrease after 'delete'.
Is this because the heap allocator holds the deleted memory for future
use? Is there anyway to force the release of the memory since we
confront problem of memory allocation failure if the delete memory is
not really released.
There is also the possibility your freestore is fragmented.
If there are deleted chunks of memory in the middle of
the freestore, it is unlikely these will be given back
to the OS. Indeed, in extreme situations, you can wind
up walking your freestore and running out of memory when
you only have a very small amount of actually-used memory.
You can sometimes get a profiling tool to detect such
situations. (Though it's off topic here. Ask in a news
group dedicated to your compiler and operating system.)
If that is the case, and it is a problem, there are many
ways to approach the situation. For example, you can take
more direct control of memory allocation, in such ways
as allocating a bunch of a particular object, then you
can re-use them as needed. Such things as a the named
ctor idiom are good places to start your research.
Socks