[lkml]   [2001]   [Apr]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: 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;
write(1,number+i, sizeof(number)-i);
int main() {
unsigned total = 0;
const unsigned size = 32*1024;

while (malloc(size)) {
total += size;
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
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:24    [W:0.070 / U:15.244 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site