View Single Post
Old 02-21-2012, 11:36 PM   #17
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by cscat View Post
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
Code:
free -m
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'.

Last edited by knc1; 02-21-2012 at 11:47 PM.
knc1 is offline   Reply With Quote