I’m having trouble finding from where this memory leak is occurring. I’m running Ubuntu 8.04 LTS on a Dell XPS M1530. I have 3GB of ram and I’m finding after about an hour or so of use top shows me 2GBs+ used. The strange thing is when I add up the memory percentages by PID either from top or ps aux I find that I should only be using about 20-25% of my available ram.
What brought this to my attention was I’ve begun running vmware server again. Now, obviously the ram usage spikes when I load a virtual machine, but the memory VMware is using does not account for the memory usage I’m seeing via top or free. Stopping vmware server releases the memory which was allocated to it, but I’m still unable to find where this RAM is being used. After a complete reboot, of course, the memory is fine, but very quickly it climbs to 60-80% usage with the processes only appearing to account for a third of that. Any ideas where I should look for more information on what this could be?
Are you using your swap at all?
If not I wouldn’t worry. Linux likes to use spare memory to cache disk blocks.
If you’re convinced you actually have a memory leak, I’d investigate the drivers you’re using. Binary-only drivers are hard to debug so I would expect them to maybe have leaks.
Congratulations, it’s the same “bug” that “hurt” Windows 7 users 🙂 Linux uses (and did so for at least the last ten years) the unused RAM to cache disks and buffer various data. Microsoft recently realised it’s a helluva good idea, and many people complained about this recently. Search for “windows 7 memory leak” for fun 🙂
Check out your “real” memory usage with the command “free”. Note that linux keeps stuff in memory as long as possible, since you might use it again. Thereby it creates a big cache/buffer usage of memory.
Edit in response to Keeners comment:
total used free shared buffers cached Mem: 4058084 3974976 83108 0 89152 3520952 -/+ buffers/cache: 364872 3693212 Swap: 2040212 157048 1883164
Did you check the line “-/+ buffers/cache” (which i doubt you can see this clear in top), did you than still have very little space free in that line? Because as you can see in my example that’s the “real” free memory whereas in the first line or in top you only see a pretty useless value for free. Now I just want to make sure you understand the output, because if you already looked at free as you said, you would have seen you don’t have a leak and your machine is just caching like you say in your final comment to the solution.
You can try the command below to free the cache without restarting the server. Check with
top before and after the command.
echo 1 > /proc/sys/vm/drop_caches