system doesnt reclaim the freed memory after free()
In our application we do huge amounts of allocations (malloc) and deallocatoins (free) in bursts. But when the per process vm size or % MEM is checked the memory used doesn't come down after the free is done.
It comes down only after some other new allocations/deallocations happen.
Have tried with EF builds as well but was of no use.
Any pointers would be greatly appreciated.
There's not necessarily a 1::1 relationship between memory you "malloc()" (a C runtime library function) and memory allocated to your process (at the kernel level).
The same is true of any modern OS, btw. You would encounter pretty much the same thing if you happened to be running your app on Windows, on Mac OS X or on Solaris.
When an application allocates and frees memory, it's actually using application-level code which (as necessary) turns to the operating system to obtain chunks of memory to add to its pool of available storage. The application-level code then suballocates the large chunks of storage it has thus obtained.
Usually, these chunks are not "given back" to the operating system until the application ends, or when a chunk is found to be completely free (and perhaps, has been so for some time). It takes a lot of time to go to the operating system to get more storage.
Also remember that all of the storage obtained by an application is virtual, which means that storage really isn't being "wasted." Application storage management routines are designed to be favorable to virtual storage implementations.
The application behavior you are seeing is by-design.
|All times are GMT -5. The time now is 12:35 AM.|