Subject: Re: killed: out of swap
To: Vesbula <vesbula@yahoo.co.uk>
From: Michal Pasternak <michal@pasternak.w.lub.pl>
List: netbsd-help
Date: 01/03/2004 23:04:30
--ew6BAiZeqk4r7MaW
Content-Type: text/plain; charset=iso-8859-2
Content-Disposition: inline

Vesbula [Sat, Jan 03, 2004 at 10:43:58PM +0000]:
> Hello, adding swap does not help me. If I do that the
> process will effectively stop running.

Is your system mis-configured or something like that?

> What happens is
> that the process

Which process?

What does it do?

What does gdb show when you break when "the process will effectively stop
running" ?

> What I'm looking
> for is a way allocate maximum memory for one process.

Try the attached program then. 

Remember, that datasize is not the only value you have to remember about
when stress-testing your machine. Stacksize also does count.

--ew6BAiZeqk4r7MaW
Content-Type: text/plain; charset=iso-8859-2
Content-Disposition: attachment; filename="maxmem.c"

#include <stdio.h>
#include <stdlib.h>

main() {
   unsigned int a;
   void *foo;
   
   for (a=0;a<1 << 31;a+=1024){
      foo = malloc(a);
      if (foo==NULL) {
	 printf("I can allocate as much as %i Kbytes.\n", (a - 1024)/1024);
	 exit(0);
      }
      free(foo);
      
      if (!(a % 1024000))
	printf("Allocated %i MB\n", a / 1024000);
   }
}

--ew6BAiZeqk4r7MaW--