How to free memory without rebooting?
Posted on 2006-05-02
In my lan I have a linux box that I keep running day and night and that I use for local web tests (php, mysql scripts).
Details: AMD Athlon(TM) XP2100+, 512 MB ram, 1.5 GB swap, 7 GB of free space available.
The other day I was browsing an application that I created using WordPress and it was damn slow. I tried the shell command "free" and in fact I saw all the memory (more than 500 MB) was used and also the swap was being used. I remembered my hosting provider (which sucks) that was often slow the same way. As solution they usually reboot their server in the night :-S ... I did the same and after reboot the the memory usage was about 150 MB. No X Server. Just apache, mysql, samba, dovecot pop3 server and some other startup applications.
Now I know why the memory usage was so high: I was downloading from irc (irssi command line irc client) a file of 700 MB.
I downloaded another file during this night, I closed irssi but now the memory usage appears as follows:
total used free shared buffers cached
Mem: 516472 502744 13728 0 50268 303120
-/+ buffers/cache: 149356 367116
Swap: 1566328 0 1566328
Now my webserver runs quite fast but I want to know if there is a way to manually free memory in case I get slowness again.
Under windows (win95, win98) I remember there were some tools like "freemem" to manually clean hundreds of MB of used memory. Is there a linux command or tool to clean all unnecessary memory without rebooting the system?
Thanks fro letting me know.