*BSD News Article 23338


Return to BSD News archive

Newsgroups: comp.os.386bsd.questions
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!elroy.jpl.nasa.gov!usc!hela.iti.org!widener!dsinc!jabber!candle!root
From: root@candle.uucp (Bruce Momjian)
Subject: Re: Swap staying full?
References: <2b9g97$93g@terminator.rs.itd.umich.edu> <CFz4Cr.2xw@candle.uucp>
Organization: a consultant's basement
Date: Fri, 5 Nov 1993 03:21:30 GMT
X-Newsreader: TIN [version 1.2 PL2]
Message-ID: <CG01Bu.65E@candle.uucp>
Lines: 55

Bruce Momjian (root@candle.uucp) wrote:
: I have the same problem under BSD/386.  Karels is working on it.  As
: soon as I hear something, I will try to get permission to distribute it
: to the 386bsd groups.  I am also running in 5MB ram.

I am following up to myself.  Let me give the details.  Symtoms:

	After a fresh reboot, system stays up for several days

	Free swap space slowly decreases

	As swap remaining hits zero, machine locks up, no message given

I have found that:

	Unrecovered swap space is allocated in 32 block (16k) pieces.
	
	The pagedaemon is the current process when the swap is allocated.
	
	Here is a program that causes it to happen.  I have 5MB of RAM,
	so it malloc's 10MB in 1MB chunks, accesses every 1k block, 
	then exists.  Each time it is run, I loose usually some multiple
	of 32 blocks from my swap, (4*32, 10*32, etc.).  I just run it over
	and over, and watch the swap disappear.  It happens even in single
	user mode.  With 20MB of swap, it takes about 2-3 hours to crash.


#include <stdio.h>

int k = 1024;
main()
{
	int i,j;
	char *x;
	
	for (i=0; i < 10; i++)
	{
		if ( (x=malloc(k*k)) == NULL)
			exit(1);
		
		for (j=0; j < k*k; j+=k)
		{
			*x = 'x';
			x += k;
		}
	}
	puts("malloc'ed");
	sleep(1);
}

-- 
Bruce Momjian                          |  830 Blythe Avenue
root%candle.uucp@bts.com               |  Drexel Hill, Pennsylvania 19026 
  +  If your life is a hard drive,     |  (215) 353-9879(w) 
  +  Christ can be your backup.        |  (215) 853-3000(h)