Date: Wed, 05 Jun 2002 23:56:57 -0500 From: Stephen Montgomery-Smith <stephen@math.missouri.edu> To: freebsd-hackers@freebsd.org Subject: allocating memory Message-ID: <3CFEEB99.AEDC5DB9@math.missouri.edu>
next in thread | raw e-mail | index | archive | help
I have access to a rather large computer (3GB of RAM) and I would like to write a program to access most of this memory. I find that I am unable to malloc more than about 0.5 GB of memory, even if I do it in small increments. Now I am trying mmap, and this lets me get to about 2.5 GB of memory (again I ask for the memory in small increments). What is it that causes these limitations? Here is the kind of program I used to find these limits: #include <stdlib.h> #include <unistd.h> #include <stdio.h> #include <sys/types.h> #include <sys/mman.h> #define size 100000000 #define nr 100 main() { char *a[nr]; unsigned int i, j; for (j=0;j<nr;j++) { fprintf(stderr,"Mallocing a[%d] with %d bytes\n",j,size); a[j] = mmap(NULL,size,PROT_READ|PROT_WRITE,MAP_ANON|MAP_NOCORE,-1,0); fprintf(stderr,"%d\n",(int)(a[j])); if (a[j]==MAP_FAILED) { perror("malloc error"); exit(EXIT_FAILURE); } fprintf(stderr,"Filling a[%d]\n",j); for(i=0;i<size;i++) a[j][i] = i; fprintf(stderr,"Done\n"); } while(1){} /* so the program doesn't stop and stays at the top of top */ } -- Stephen Montgomery-Smith stephen@math.missouri.edu http://www.math.missouri.edu/~stephen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3CFEEB99.AEDC5DB9>