Skip to main content.
home | support | download

Back to List Archive

Re: more out of memory fun

From: Peter Karman <peter(at)not-real.peknet.com>
Date: Fri Oct 20 2006 - 13:12:40 GMT
David L Norris scribbled on 10/19/06 9:44 PM:

> But if your OS and CPU are not both 64-bit (and swish-e also isn't
> 64-bit) there's probably a hard limit of 2 GB per process.
> 

Brad, Mr Intrepid Hero, is this box a 64-bit machine? Is that version of FreeBSD 
a 64-bit OS? I suspect Dave might be on to something here. I see this issue (2g 
ram limit) frequently right now with one of our db servers, where it's stuck on 
a 32bit machine and runs out of memory even though there's plenty of ram available.

Here's a little C program you can use to test the mem limit on your machine:

---------------- snip here ------8<------------------------
#include <stdio.h>
#include <stdlib.h>

int main ( void )
{
     size_t siz = 100 * 1024 * 1024 ;
     size_t idx = 1 ;
     void *ptr ;

     for (;;)
     {
         ptr = malloc ( siz * idx );
         if ( ! ptr )
             break ;
         free ( ptr );
         idx ++ ;
     }
     printf ( "Max malloc %d * 100 MB \n", idx - 1 );
     return ( 0 );
}
---------------- snip here ------8<------------------------

just compile it like:

  cc -i checkmem.c -o checkmem

and run:

  ./checkmem

that'll tell you how much memory a single process can allocate on your machine.

-- 
Peter Karman  .  http://peknet.com/  .  peter(at)not-real.peknet.com
Received on Fri Oct 20 06:12:48 2006