Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

After reporting strange Eclipse memory errors ( 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

share|improve this question
I am VERY happy I am not crazy. I've had the same problem since upgrading to 13.10, but i remember having it with 11.10. The question is: Are you using CrashPlan? I seem to have it narrowed down to that, i just don't know how to fix it. I've tried the memory tweaks, but it is not working. I hope it gives you some clues –  semi-newbie Nov 30 '13 at 17:59

3 Answers 3

up vote 3 down vote accepted

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.


Source: Ubuntu Manual

share|improve this answer

The drop_cache trick will not free memory, it will reset the cache. Uses ps command if you want to identify which processes uses the more memory.

For instance to monitor the list of the top 15 of resident memory users.

$ watch "ps --sort rss -eo pid,pmem,rss,vsz,comm | head -16"
 2590 13.4 136892 825000 firefox
 1743 10.7 109020 300780 Xorg
 2067  8.5 86764 1118140 unity-2d-shell
 3307  4.1 42560 627780 unity-2d-spread
 2068  2.9 29904 617644 unity-2d-panel
 2092  2.5 25524 1291204 nautilus
 2457  1.9 20292 530276 gnome-terminal
 2351  1.9 20016 821488 unity-scope-vid
 2161  1.9 19476 531968 unity-panel-ser
 2034  1.7 18256 759716 gnome-settings-
 2074  1.5 16176 518016 nm-applet
 2273  1.5 15452 580416 unity-lens-vide
 2051  1.4 15112 524260 metacity
 2395  1.2 12836 407336 update-notifi

You could check also the shared memory reservation but you will only know who is the owner of the segments.

Pmap allocation:

$ ls -l /run/shm
total 272
-r-------- 1 ed      ed      67108904 Nov 29 18:17 pulse-shm-1884617860
-r-------- 1 lightdm lightdm 67108904 Nov 29 18:11 pulse-shm-2352897759
-r-------- 1 ed      ed      67108904 Nov 29 18:12 pulse-shm-3444873503
-r-------- 1 ed      ed      67108904 Nov 29 18:12 pulse-shm-3485341848
-r-------- 1 lightdm lightdm 67108904 Nov 29 18:11 pulse-shm-535843976
-r-------- 1 ed      ed      67108904 Nov 29 19:12 pulse-shm-789046959
-r-------- 1 ed      ed      67108904 Nov 29 18:38 pulse-shm-863909656

$ df /run/shm 
Filesystem     1K-blocks  Used Available Use% Mounted on
none              509332   272    509060   1% /run/shm

note that reserved allocations are much higher than real the allocated pages (df 'used')

System V allocations :

$ ipcs -m 

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x00000000 294912     ed         700        122880     2          dest         
0x00000000 327681     ed         700        4823040    2          dest         
0x00000000 491522     ed         600        393216     2          dest         
0x00000000 589827     ed         700        4578120    2          dest         
0x00000000 425988     ed         700        27852      2          dest         
0x00000000 458757     ed         600        393216     2          dest         
share|improve this answer

memstat is also a good tool that will show the amount of memory used by each block as well as how much memory is used by loaded libraries. Not the best tool but is worth using to gather details and statistics.

memstat -w -p pid is a good command to use.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.