LWN.net Logo

More memory - less OOM situations

More memory - less OOM situations

Posted Jun 17, 2010 23:38 UTC (Thu) by efexis (guest, #26355)
In reply to: More memory - less OOM situations by NAR
Parent article: Another OOM killer rewrite

Is it definitely leaky, as opposed to perhaps it coincides with backups or something io intensive that can fill your page cache, vacating stuff out to swap.

One horrible but quick fix for that is to have something like this set to run in the morning so everythings loaded back into memory ready for you to use it:

#!/bin/bash
getnum() {echo $2}
cached=$( getnum `grep ^Cached: /proc/meminfo` )
memFree=$( getnum `grep ^MemFree: /proc/meminfo` )
swapTotal=$( getnum `grep ^SwapTotal: /proc/meminfo` )
swapFree=$( getnum `grep ^SwapFree: /proc/meminfo` )
swapped=$(( $swapTotal - $swapFree ))
available=$(( $cached + memFree ))
[[ "$available" > "$swapped" && "$swapped" > 0 ]] && {
	echo "Loading everything back from swap"
	swapoff -a
	echo "Enabling swap again"
	swapon -a
}
And of course if it isn't that then it won't bother doing anything so at least there should be nothing to lose! More elegant fixes depend on your setup.


(Log in to post comments)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds