Tuning for very little RAM

Ian Smith smithi at nimnet.asn.au
Sat Jan 9 04:49:25 UTC 2010

In freebsd-questions Digest, Vol 292, Issue 8, Message: 13
On Wed, 6 Jan 2010 15:52:59 +0000 Bruce Cran <bruce at cran.org.uk> wrote:
 > On Tue, 05 Jan 2010 20:03:45 +1000
 > Da Rock <freebsd-questions at herveybayaustralia.com.au> wrote:
 > > Its been a while- work's has been keeping me very busy for months now.
 > > 
 > > I have revived an old laptop which has very little RAM, and it is
 > > absolutely hammering the swap.
 > > 
 > > I'm trying to set it up as a demo for some skeptics with no money, so
 > > I need email, internet (with plugins), openoffice, acrobat, and wine.

[Rock, mate, you may be on a hiding to nothing trying to run X apps in 
100MB (128MB fitted I guess?) while setting yourself up as the advocate 
of an OS they're going to think is soooo slow .. but that's just me :-]

With a lightweight wm it may be better, but you're talking about some 
big apps.  OTOH, 256MB is plenty for that sort of usage; any chance of 
adding more RAM to it?  Even another 32MB will really help ..

 > > Aside from all that though, for the academics of it how can I help
 > > this situation? The laptop has around 100MB RAM, with 16k free, and
 > > has a new install of FreeBSD 8.0.

I just manage with 160MB on a old Celeron 300 laptop whose prime mission 
is pppoe, firewall, nat and routing for the LAN, half a dozen obscure 
websites, DNS, mail and such .. plus until now, KDE 3.5 on Xorg 6.9 on 
5.5-STABLE.  Just!  That with 30-40% swap (of 384MB) in use, but mostly 
static, eg 6 more Konsoles I'm not using just now, 5x minimised kwrites 
for sources I may edit a few times a week, stuff like that stashed away 
in swap, using very little resident memory, ie not as bad as it looks :)

 > You can save a bit of memory by building a custom kernel. First, remove
 > any options you don't need such as INET6, NFS, AUDIT etc. Then, you can
 > replace "device ata" with more specific drivers, and "device mii" with
 > specific PHY drivers for your NIC. On a 128MB box I have that's running
 > 8-STABLE my kernel is just 4.1MB.

Indeed.  That's no bigger than my trimmed 5.5 kernel, good to hear.

 > You should also be able to build Xorg so it'll use less memory - for
 > example by not requiring hald but getting it to read the
 > configuration from xorg.conf instead.

Again talking on the margins of usability, I notice that the Xorg with 
7.0-RELEASE (X server 1.4.0) only used similar memory to 6.9 (30-50M, 
say 20M resident), but on 8.0-RELEASE (X server 1.6.1) top shows SIZE 
126M RES 115M .. on a 256MB laptop, eek!  It's a HAL-free config, though 
installed from packages so not at all optimised.  Will try that later, 
while I'm hunting for 1G RAM at a decent price for it (Thinkpad T23)

 > You can also tell FreeBSD to agressively swap idle processes out by
 > setting vm.swap_idle_enabled to 1.

Thanks for this, Bruce; I hadn't come across it before, or missed it.

This has had an amazing and so far apparently only beneficial effect on 
the 5.5 box.  At 127d uptime, I crossed my fingers and set that, to see 
swap drop from its then steady 46% (~15 mozilla tabs open, past time to 
restart the leaky thing anyway :) to below 40% in a matter of minutes.

A little extra (async) swap in/out activity for sure, but contrary to 
expectations it's noticeably more responsive to things like switching 
desktops/windows on a slow machine already under swap stress, and even 
somehow(?) has increased idle CPU in top by about 3% to over 90%!

cheers, Ian

More information about the freebsd-questions mailing list