Swap partition

Tom Mitchell mitch48 at sbcglobal.net
Sun Dec 14 14:43:11 UTC 2003

On Sat, 13 Dec 2003, Chris Sparks wrote:
> Hi Gregory,

> >The "easy" thing to do in this case is abandon the miminal swap you have
> >and just make another (larger) swap partition to be used instead.  The
> >size of a swap partition is a matter of debate, but generally it sould
> >be equal to or no more than twice as large as your physical memory.
> >
> Since I originally started with 128 MB this makes sense why it
> suggested 256 MB.  I had to increase the memory to 384 MB
> because of the boat load of seg faults I was getting.

If your disk is fully allocated you cannot increase your swap
partition without risking damage to the existing file systems. (a
backup and restore will be needed)

However most swap related seg faults are book keeping checks not
active block transfers so swap to files is a good solution!
Compare and contrast calloc() and malloc().

When adding swap files, you will want to add pri=0 to the fstab
for your existing 'raw' swap partition.

Then add your swap file with a larger priority to the system and

If you already have a swap file in addition to a swap partition
and are still running out of 'virtual' memory you have the option
of rebuilding the swap file to be larger or simply adding a
second swap file at a higher priority.

I happen to like having layers of swap and when things actively
swap to the high priority swap files I likely have an application
or mix of applications to get fixed.  Adding a swap file is much
safer (IMO) than repartitioning a disk with data.  

Do you have an old 2-4GB disk you can use for swap?
If you can add a dedicated swap device you may want it to
have the best priority if it is fast enough.

See also "ulimit", there are lots of 'student' programs that
would allocate memory up to the imposed limits then work within
those bounds imposed by the administrator.  Since most students
never had unlimited resources they never code for it.  The
reverse may be true, check also ulimits just in case it is not
swap that is the limiting resource.

Recursion is cool but....
# bc
define f ( x ) {
   if( x != 1) return( x * f(x-1) )
   if(x == 1 ) return(1)
x = 15
x = 200000

	T o m  M i t c h e l l
	mitch48 -a*t- yahoo-dot-com

More information about the users mailing list