Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Are there any tools to detect memory leaks of running programs in Linux? I know of Valgrind, but it's mostly used to debug for memory leaks and not simply to detect memory leaks.

share|improve this question
    
If you just want to find out which process is leaking, you could run atop and collect stats about per process memory usage over time. –  AnonymousLurker Jul 13 '13 at 18:51

1 Answer 1

up vote 0 down vote accepted

I'm not sure, but something I have observed on my Minecraft server is the ever going memory cache its taking. To counter against the cache taking all the memory I run these commands in cron every day....

Command

sudo sync
sudo echo 3 | sudo tee /proc/sys/vm/drop_caches

free_memory.sh

#!/bin/bash
echo -e "\033[36mMemory before\033[0m"
free -m
sudo sync
sudo echo 3 | sudo tee /proc/sys/vm/drop_caches
echo -e "\033[32mMemory after :)\033[0m"
free -m
share|improve this answer
3  
The cache taking up all the memory is a good thing. RAM is still much faster than disk, and cache always gets discarded automatically whenever a process allocates memory for itself. –  grawity Aug 16 '11 at 10:00
    
True. Unfortunately there are some programs, like the Minecraft server, that love to take up some memory, and even use a little bit of my swap space (*_*). That's why once a day is great for any long uptime computers. I'm not so sure what Rayne wants to do. There are already tools that report memory use and debug tools to detect leaks. If it's those slow memory hoggers, then I prescribe this simple bash script or submitting a bug report to stop the leaks. –  Koodough Aug 23 '11 at 5:01

Your Answer

 
discard

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.