Search code examples
c++memorydictionarymemory-leaksdeque

Memory Leakage in a long run C++ application


I am running a long run C++ application which allocates different objects and store it in several deque and maps,and deallocate these object from these data structures at a time.I'm experiencing a small amount of increase in memory(generally 1 mb to 2 mb) day by day.I have run memory leakage detector(valgrind),but i could'nt find any suspicious memory leakage. I was wondering whether the problem is with the deque and maps where the objects are stored. Whether the memory of deque and map releases the memory to OS as soon as object is popped from the data structures? Can anyone please point out solutions or general possible cause for the increase in memory?


Solution

  • C++ standard provides no guarantees that delete will release memory to the OS. In fact many standard C++ libraries do not do this. If you want memory to be released to the OS then you will have to use your OS's own memory allocation routines.

    Standard C++ library provides custom allocators which might help you do this.