CodeJuan / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Heap profiler consumes a lot of memory #671

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I am testing the heap profiler to track memory leak in my application.

It works well but when I activate the heap profiler on my runtime, the memory 
usage of the app grows strongly (1 MB/sec) until my machine ends in OOM (over 
15 GB RAM used).

I use the profiler like this (link with tcmalloc at runtime):

LD_PRELOAD=libtcmalloc.so.4.2.4 HEAPPROFILE=<path_to_output_files> <MyBinary> 

Thank you!
Chris

Original issue reported on code.google.com by lebars.c...@gmail.com on 30 Jan 2015 at 9:53

GoogleCodeExporter commented 9 years ago
BTW if you you're checking leaks you should be using HEAPCHECK as opposed to 
HEAPPROFILE which is for profiling.

In both cases tcmalloc spends some memory for all allocations to track whether 
it's free or not and where it was allocated. So there is some (possibly large) 
multiplier of memory used by your app spent on tracking memory.

If I'm right than your program indeed leaks memory and tcmalloc heap profiler 
overhead simply makes it worse. In that case consider:

a) using heap checker rather than heap profiler

b) making your program exit sooner, before it exhausted all RAM

c) or consider some programmatic API that allows checking for leaks at runtime 
(see heap checker documentation)

I'm going to mark this bug as NotABug because memory usage of heap 
{profiler,checker} is by design. But there is of course some chance that you're 
hitting some bug in tcmalloc. If so, please reopen this ticket with more 
evidence after you've checked it's not your program's fault.

Original comment by alkondratenko on 7 Feb 2015 at 7:30