Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'sizing swapfiles to match physical RAM' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
sizing swapfiles to match physical RAM
Authored by: mblakele on Dec 13, '02 02:37:34AM

If you like the idea of having swapfiles sized to match physical RAM, here's how to do it. In /etc/rc, find the line that starts dynamic_pager. Comment it out, and add this code:

# this give us physical RAM in hex
RAMSIZE=`/usr/sbin/nvram ram-size | /usr/bin/cut -d x -f 2-`
# convert to decimal
VM_SIZE=`/bin/echo "ibase=16; $RAMSIZE" | /usr/bin/bc`
# high-water mark is 40MB (arbitrary)
VM_HIGH=41943040
# low-water mark is high-water + VM_SIZE + 1
VM_LOW=`expr $VM_HIGH + $VM_SIZE + 1`
dynamic_pager -H $VM_HIGH -L $VM_LOW -S $VM_SIZE -F ${swapdir}/swapfile

Depending on Apple's pager implementation, there may be some advantage in having one large swapfile vs. several small ones. My ibook (384MB) and imac (256MB) seem snappier with these settings, but that may be my imagination.

Note that the above code uses programs found in /usr/bin, /usr/sbin, and /bin, so it should be safe to run as long as /usr is on your boot volume.



[ Reply to This | # ]