
On Mon, 21 Nov 2011, "Trent W. Buck" <trentbuck@gmail.com> wrote:
AIUI "twice the RAM" is advice for pre-Linux unices that did something particularly dumb -- maybe stop-and-copy paging or something.
It's for Unix systems that allocated a page in swap for every page in virtual memory.
IMO, the Right Thing is to
1. no swap. If you need 2GB of memory, buy 2GB of RAM;
That's almost never the best advice. There are always pages that never get accessed after initialisation and can be paged out. I even use swap on my EeePC 701...
2. no RAM overcommit. This means malloc returns an error rather than handing the problem over to the OOM killer.
Given that RAM is cheap and disk space is usually plentiful that's a viable option nowadays. Of course you will probably encounter programs that malloc() vastly more memory than they need which happen to work well on the majority of Linux systems.
3. fix any programs that make inappropriately large, up-front mallocs; likewise those that do not handle errors from malloc appropriately (even if "appropriately" means asserting malloc success).
Obviously this advice is inappropriate in some contexts - varnish obviously springs to mind.
Also most people on this list aren't capable of following step 3. Even I would be hesitant to do that, I already have enough bugs to fix. -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/