Ubuntu – How to detect a memory leak

memory leak

I seem to have a larger memory leak on my current ubuntu System

After reporting strange Eclipse memory errors ( https://askubuntu.com/questions/148998/eclipse-constant-different-out-of-memory-errors ) I started to get 'Not enough Memory' error messages in my console today – while doing simple tasks like typing in sudo -s – or even – free -m

Typing in 'free -m' repeadetly showed me how my RAM quickly goes up from 700M to 900M, growing up to the size of 2000M in a few seconds (after freeing up memory with echo 3 > /proc/sys/vm/drop_caches )

Eclipse isnt the cause, I completly killed the process and the ram still was going up. Is there any way to detect where the leak is coming from? I cant even update my system anymore, since apt-get update fails (probably because it's out of memory)

Using Ubuntu 11.10

Best Answer

memprof is a tool for profiling memory usage and finding memory leaks. It can generate a profile how much memory was allocated by each function in your program. Also, it can scan memory and find blocks that you’ve allocated but are no longer referenced anywhere.

memprof works by pre-loading a library to override the C library’s memory allocation functions and does not require you to recompile your program.

memprof

Source: Ubuntu Manual

Related Question