|
From: Jason W. <jas...@bl...> - 2004-01-13 18:54:06
|
Hi, I am trying to track down a memory leak in an application. The memory leak is proving difficult to track down - valgrind's memleak check does not pick it up, which suggests to me that the memory is being cleaned up at exit, but is not being managed correctly while the app is running. Does anyone know of a way to take a memory "snapshot" - something like a list of all memory currently allocated, grouped by the file line number of where it was allocated, and sorted by the amount of memory that is allocated. I feel that such a thing would let me solve this issue very quickly :-) Cheers, Jason -- Jason Wood Homepage : www.uchian.pwp.blueyonder.co.uk |
|
From: Tom H. <th...@cy...> - 2004-01-13 19:14:12
|
In message <200...@bl...>
Jason Wood <jas...@bl...> wrote:
> Does anyone know of a way to take a memory "snapshot" - something like a
> list of all memory currently allocated, grouped by the file line number of
> where it was allocated, and sorted by the amount of memory that is
> allocated. I feel that such a thing would let me solve this issue very
> quickly :-)
You can use the VALGRIND_DO_LEAK_CHECK client request in your program
to request a leak check at any time and if you used --show-reachable=yes
when starting valgrind then it will show all blocks, but I'm afraid
you'll have to handle the resorting of the output yourself.
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|
|
From: Nicholas N. <nj...@ca...> - 2004-01-17 13:32:10
|
On Tue, 13 Jan 2004, Jason Wood wrote: > I am trying to track down a memory leak in an application. The memory leak is > proving difficult to track down - valgrind's memleak check does not pick it > up, which suggests to me that the memory is being cleaned up at exit, but is > not being managed correctly while the app is running. > > Does anyone know of a way to take a memory "snapshot" - something like a list > of all memory currently allocated, grouped by the file line number of where > it was allocated, and sorted by the amount of memory that is allocated. I > feel that such a thing would let me solve this issue very quickly :-) You could also try Massif, a Valgrind tool that does heap profiling -- it gives you a graph, and an accompanying text or HTML file with lots of info showing which call-stacks are responsible for most of the memory usage. It can be useful for finding memory leaks like this. See www.cl.cam.ac.uk/~njn25/valgrind.html; you'll have to download and install the whole Valgrind with Massif in it, but we're considering putting Massif into the main distro. Failing that, mpatrol (www.cbmamiga.demon.co.uk/mpatrol/) might be able to give you the snapshot you want. HTH N |