From: Julian S. <js...@ac...> - 2003-04-26 09:58:54
|
Yes it is definitely one for the recently-expanded FAQ. Some more info (or the complete FAQ entry :) would be helpful. Specifically, can you say how to disable the STL's memory pooling, since that will be the next thing that people ask having read the below. Thx J On Saturday 26 April 2003 10:42 am, Bastien Chevreux wrote: > On Saturday 26 April 2003 02:03, Lee, HJ wrote: > > If I use string type for example ---> string a("Hello, world"), the > > memory allocated for string isn't freed when program exit. > > valgrand reported it is not-freed block. Here is valgrind reports logs. > > Why is it not freed when program exits? I am using RH6.2. > > The thread ""Reachable" memory, where's the bug (g++, STL, valgrind)?" > might help you there. In short: the C++ STL and string function have their > own memory pooling mechanisms to gain speed. The memory of these objects is > not 'freed' per se when they are destructed, but returned to the internal > memory pool and will be reused for other objects created. It's these pool > fragments (which are not freed by the C++ library before exit) that > valgrind chokes on. > > While you can minimise this behaviour with the STL by providing your own > allocators (not recommended, slows down execution speed terribly on some > systems), I am not aware of similar mechanisms for the string classes. > > Salut, > Bastien > > PS: This is _definitively_ something for the FAQ. |