On one of my computers, my RAM was being eaten up and I couldn't figure out why. Running 'top' resulted in the following line:
Mem: 505908k total, 478736k used, 27172k free, 41888k buffers
Out of my half gig of ram, 95% was being used. Browsing the list of processes didn't give any indication that there were any particular memory hogs.
Running 'free -m' (the -m prints in megabyes instead of the default kilobytes) resulted in the following output:
total used free shared buffers cached
Mem: 494 469 25 0 41 315
-/+ buffers/cache: 112 381
From that, I was able to discover that the majority of my RAM was tied up in caching data. Not necessarily bad, since if you have spare RAM lying around, you might as well use it for something, but it was slowing down my SSH terminals to the point where they were effectively unusable. The previous couple times I had this problem, I had simply rebooted, but that was a hammer=nail solution and I wanted a better one. I finally found the solution on ubuntu-unleashed.com.
- Flush file system buffers for safety
- user$ sync
- Become root (simply sudo-ing the final command won't work because of the redirection)
- user$ sudo bash
- Free cached memory
- root# echo 1 > /proc/sys/vm/drop_caches
Mem: 505908k total, 120384k used, 385524k free, 204k buffers
Additionally, 'free -m' resulted in the following:
user$ free -m
total used free shared buffers cached
Mem: 494 128 365 0 0 24
-/+ buffers/cache: 103 390
6 comments:
Excellent tip, I am still learning my around Ubuntu and memory is being eaten up everywhere. I was wondering how to force the system to recalibrate.
If this is a duplicate posting - sorry but the identity mechanism leaves me in the dark.
This post is very helpful, I am still learning the ins and outs of Ubuntu and I've been wondering how to do just this. Memory is being allocated from boot and I now have a way to recalibrate it the fly. Excellent.
Is there a way to configure Ubuntu to flush its own cache when system resources become scarce?
I haven't explored the possibilities. You obviously could script this, but if you're getting this problem, it probably speaks of some deeper problem in the system.
I haven't explored the possibilities. You obviously could script this, but if you're getting this problem, it probably speaks of some deeper problem in the system.
I haven't explored the possibilities. You obviously could script this, but if you're getting this problem, it probably speaks of some deeper problem in the system.
Post a Comment