Linux tool to detect memory leak

1

1

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.

Rayne

Posted 2011-08-16T09:30:46.653

Reputation: 479

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 – 2013-07-13T18:51:56.300

Answers

0

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

Koodough

Posted 2011-08-16T09:30:46.653

Reputation: 52

3The 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. – user1686 – 2011-08-16T10:00:45.943

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 – 2011-08-23T05:01:00.343