Messages in this thread |  | | | Date | Thu, 06 Jan 2000 11:48:40 -0500 | | From | Larry Woodman <> | | Subject | Re: Can a process use up more than 910MB? |
| |
Peter Tufvesson wrote:
> Hi all, > > I have now tried the program below on 2.2.12, 2.2.13, 2.3.36 (High memory > support: Off, 4GB and 64GB) with the same result: > > My program can only allocate 910MB !!! > > What can be done about this? I need at least 2GB of virtual memory per > process. I thought Linux could handle this? > > Thanks. > > ----------------------------------- > > #include <string.h> > #include <stdlib.h> > > main() { > int i; > void *x; > x = (void *)4; > for(i=0;x!=NULL;i++) { > x = malloc(1024); > if(x!=NULL) { > memset(x,1024,6); > if(i%1000)==0) { > printf("malloc %d\n",i/1000); > } > } > } > sleep(20); > } > > - > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.rutgers.edu > Please read the FAQ at http://www.tux.org/lkml/
You need to use mmap, malloc fails because it hits an address thats already in use. The attached very hacky program mmap()s almost 3GB and tells you which pages couldnt be allocated because there was already something mapped there(like the text of this program itself).
Also, if you use memset your program will swap like crazy unless you have 3GB of physical memory...
Larry Woodman http://www.missioncriticallinux.com
#include <string.h> #include <stdlib.h> #include <sys/mman.h>
main() { int i; void *x; long siz=0; long cantmap=0; void *loc=0; for(loc=0;loc<(void*)0xc0000000;loc+=0x1000) { x = (void *)mmap(loc,0x1000,PROT_READ|PROT_WRITE,MAP_ANONYMOUS|MAP_PRIVATE,-1,0); if(x == (void*)-1) { printf("size = %x, loc = %x, couldnt map = %x\n", siz, loc, cantmap); sleep(60); } else { siz+=0x1000; if (x != loc) { printf("mmap to %x returned %x\n",loc,x); if (loc == 0) { loc+=0x1000; cantmap = 0x1000; } else { cantmap+=(abs(x-loc)); loc = x; } } /* memset(x, 6, 0x1000); */ } } }
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
|  |