Messages in this thread |  | | Date | Fri, 6 Apr 2001 15:22:23 -0400 (EDT) | | From | Mark Hahn <> | | Subject | Re: memory allocation problems |
| |
> can get at most 2GB. Newer glibc's allow you to tune the definition > of "small" via an environment variable.
eventually, perhaps libc will be smart enough to create more arenas in mmaped space once sbrk fails. note, though, that you *CAN* actually malloc a lot more than 1G: you just have to avoid causing mmaps that chop your VM at TASK_UNMAPPED_BASE:
#include <unistd.h> #include <stdlib.h> #include <fcntl.h>
void printnumber(unsigned n) { char number[20]; int i; for (i=sizeof(number)-1; i>=0 && n; i--) { number[i] = '0' + (n % 10); n /= 10; } i++; write(1,number+i, sizeof(number)-i); } int main() { unsigned total = 0; const unsigned size = 32*1024;
while (malloc(size)) { total += size; printnumber(total>>20); write(1,"\n",1); } return 0; }
compile -static, of course; printnumber is to avoid stdio, which seems to use mmap for a small scratch buffer. I allocated 2942 MB on my 128M machine(had to add a swapfile temporarily, since so many tiny mallocs do touch nontrivial numbers of pages for arena bookkeeping.)
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |