[comp.unix.wizards] A Danger Message From UNIX

cjn@homxb.ATT.COM (C.NORTHRUP) (04/14/89)

------------------------------------------


OK people, this should be a interesting question for you.....

First, some background:

	We have a simple program with the following code fragment:

	for(i=0;i<4096;++i)
		if( (memptr[i] = malloc(80540)) == (char *) NULL)
		{
			perror("mt");
			break;
		}


Now, the scenario:
	
	While running multiple versions of this in the background, 
	(loged on as a general user) the following message started 
	appearing on the system console:

	DANGER: out of swap space.


Finally, the question:
	Since the five (or so) invocations of the program consumed
	minimal space prior to the mallocs, how should the OS
	have handled this?  Should the mallocs have failed?
	Or is this considered acceptable.

NOTE 1:	I know that increasing the swap space would make the problem
	go away, but that is not what I need to know...  The real
	question is how should the OS handle this.....
	
	
NOTE 2: This happened on a Motorola VME147A running 5.3



			- charlie northrup
			  homxb!cjn

			  at&t bell labs
			  480 red hill road
			  middletown, nj
			  (201)615-4508

** standard disclaimer implied


*********************************
 "Hank is the type of person you buy for what he is worth, and sell
  for what he thinks he is worth.  That is how you make money."
					- ajn '84
*********************************
 "A redneck is a cowboy with an attitude problem"
					- dillard '88

*********************************

root@libove.UUCP (Jay M. Libove) (04/23/89)

From article <3320@homxb.ATT.COM>, by cjn@homxb.ATT.COM (C.NORTHRUP):

> 	for(i=0;i<4096;++i)
> 		if( (memptr[i] = malloc(80540)) == (char *) NULL)
> 		{
> 			perror("mt");
> 			break;
> 		}

> 	While running multiple versions of this in the background, 
> 	(loged on as a general user) the following message started 
> 	appearing on the system console:
> 	DANGER: out of swap space.

> 	Since the five (or so) invocations of the program consumed
> 	minimal space prior to the mallocs, how should the OS
> 	have handled this?  Should the mallocs have failed?
> 	Or is this considered acceptable.

I think you'll find that the malloc() calls _did_ fail, and that
the warning message occurs because an attempt to grab that much
swap space failed - not that the system alloc'd all of the
remaining space, and now has zero free space in the swap area.

Serious counter question: What kind of application needs to
allocate 4000 chunks of 80Kbytes each, and be run five times
simultaneously?

------------- 
Jay Libove		jl42@andrew.cmu.edu, libove@cs.cmu.edu,
5731 Centre Ave, Apt 3	gateway.sei.cmu.edu!libove!libove, jl42@andrew.BITnet,
Pittsburgh, PA 15206	psuvax1!pitt!darth!libove!libove,
(412) 362-8983		or uunet!nfsun!libove!libove