From: Dave D. <dde...@es...> - 2004-07-22 17:18:11
|
Ethan Merritt <merritt@u.washington.edu> writes: > I would like to audit the memory allocation and deallocation > for strings during a gnuplot run, to make sure there are no > memory leaks. > > The existence of the routine gp_alloc(mem,"tag label") suggests that > some such facility was intended, but since there is no corresponding > routine gp_free I don't see how to use it for this purpose. > Is there some clever way of asking for a dump of the currently > allocated memory chunks? It would be nice to see the tag labels > as well, but I can worry about that later if indeed it proves necessary > to trace down a memory leak. > > I see some code in alloc.c marked > #ifdef CHECK_HEAP_USE > but it is not obvious to me how to use it. > Looks like something I might have added. The basic idea is that every block allocated by gnuplot has a header and a footer added. These have checksums which detect whether the app has scribbled (just) outside the allocated area. The header is an instance of frame_struct, which records the reason. (Usually I link these blocks together so that one can walk the list validating each block, but I don't seem to have done that here. ) The leak check looks like it is simply a means to ensure that the net memory usage has not changed between two points. So you can put start_leak_check() at the start of a plot, and end_leak_check at the end. Things like user-defined functions obviously consume memory, so it's not going to help with that. But you could test for memory leaks during string expressions by putting it around the body of the print command, for example. Then just print various expressions to see what happens. dd -- Dave Denholm <dde...@es...> http://www.esmertec.com |