Quote:
Originally Posted by cscat
5. Purge cache memory:
This very simple lovely extension purges cache memory... it means more free memory and less resources taken, which in my opinion is very important for such embedded systems. Yes I know, Linux is pretty damn good at memory management but still...
Requirements:
GUI Launcher
Install:
extract the attached file in extension folder.
Test:
First run in SSH. Then run this simple script via GUI Launcher and run free -m again to see the difference in memory usage and free memory.
|
A couple of notes:
That script presumes it is being run by the user 'root' - only 'root' has write permission on /proc/sys/vm/drop_caches
The 'sync' is not required, dropping caches causes the dirty cache entries to be written, even if the underlying file system does not support 'sync' (like FAT-32).
There is no need to pipe the output of echo through tee.
Code:
echo 3 >/proc/sys/vm/drop_caches
does the same thing, without executing another process (which would just dirty some of the just cleared VFS buffers).
And since it is now down to a single line of code, why not just assign a shell alias to that operation in /etc/profile? Your choice of alias name, but would look like:
Code:
alias dc="echo 3 >/proc/sys/vm/drop_caches"
After which, entering dc at a command prompt would 'drop_caches'.
You can be more selective than taking a big hammer to the VFS system;
You can flush the caches of any specific file system using:
Code:
mount -o remount <mount point or device>
Note: There is no argument following 'remount' above (where you might expect rw or ro)!
This is a special version of the 'remount' function intended to flush the caches of the mentioned file system's mount point (or device).
This also works on file systems that do not support 'sync'.