Re: Finding memory leak, walking the heap?
- From: Måns Rullgård <mans@xxxxxxxxx>
- Date: Wed, 20 Feb 2008 22:26:47 +0000
"Ed J" <jed@xxxxxxxxxxx> writes:
How can I embed checkpoints for memory leaks in my C++ code? I'm looking
for unfreed heap space allocated with "new" but not deleted, and I would
like to be able to ask for the current allocations in my C++ code to help me
pinpoint where the leak exists.
Essentially, I'm looking for the ability to do something like this:
long bytes_allocated = heap_space_used();
... run code here that shouldn't grow the heap
if (bytes_allocated != heap_space_used())
printf( "I found a leak");
I'm using GCC 3.3.3. Unfortunately, I'm stuck with that GCC version due to
our development environment.
One word: Valgrind.
--
Måns Rullgård
mans@xxxxxxxxx
.
- References:
- Finding memory leak, walking the heap?
- From: Ed J
- Finding memory leak, walking the heap?
- Prev by Date: Finding memory leak, walking the heap?
- Next by Date: Re: Finding memory leak, walking the heap?
- Previous by thread: Finding memory leak, walking the heap?
- Next by thread: Re: Finding memory leak, walking the heap?
- Index(es):
Relevant Pages
|