Clear Linux Kernel Memory Caches

Every so often, I find my desktop, well, Firefox that is, a bit sluggish due to the amount of memory being consumed (upwards of 2GB!). The Linux Kernel has very efficient memory management that occasionally frees any cached memory on the system. However it’s not always when you need it.

sync; sysctl -w vm.drop_caches=3

This is effectively the same as calling

sync; echo > /proc/sys/vm/drop_caches

Part of the problem I had was a left over setting from some kernel memory testing I had done some time ago, where I left this parameter set

vm.swappiness=99

This equates to 99% of memory will be cached. For the average person this could be either left to the default value (60) or omitted completely, or set to a lower value to cache less but not too little as to ruin your experience.

Unpack Debian .deb package

I recently made the mistake of forgetting the upgrade process required from Debian Etch to Squeeze which almost trashed a remote server!

Fortunately I only broke dpkg prior to anything else so only required me to unpack the old version over-top of the newer one.  I thought others might like to know this one-liner also.

ar p dpkg_1.13.26_i386.deb data.tar.gz | tar xzv -C /