Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In the FAQ section of the manual that comes with every valgrind, there is:</p> <blockquote> <p>My program uses the C++ STL and string classes. Valgrind reports ’still reachable’ memory leaks involving these classes at the exit of the program, but there should be none.</p> <p>First of all: relax, it’s probably not a bug, but a feature. Many implementations of the C++ standard libraries use their own memory pool allocators. Memory for quite a number of destructed objects is not immediately freed and given back to the OS, but kept in the pool(s) for later re-use. The fact that the pools are not freed at the exit of the program cause Valgrind to report this memory as still reachable. The behaviour not to free pools at the exit could be called a bug of the library though.</p> <p>Using GCC, you can force the STL to use malloc and to free memory as soon as possible by globally disabling memory caching. Beware! Doing so will probably slow down your program, sometimes drastically.</p> <p>• With GCC 2.91, 2.95, 3.0 and 3.1, compile all source using the STL with -D__USE_MALLOC. Beware! This was removed from GCC starting with version 3.3.</p> <p>• With GCC 3.2.2 and later, you should export the environment variable GLIBCPP_FORCE_NEW before running your program.</p> <p>• With GCC 3.4 and later, that variable has changed name to GLIBCXX_FORCE_NEW.</p> <p>There are other ways to disable memory pooling: using the malloc_alloc template with your objects (not portable, but should work for GCC) or even writing your own memory allocators. But all this goes beyond the scope of this FAQ. Start by reading <a href="http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#4_4_leak" rel="nofollow">http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#4_4_leak</a> if you absolutely want to do that. But beware: allocators belong to the more messy parts of the STL and people went to great lengths to make the STL portable across platforms. Chances are good that your solution will work on your platform, but not on others.</p> </blockquote> <p>Possibly your problem is related. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload