max memory allocation

Brad Fitzpatrick brad@danga.com
Thu, 8 Apr 2004 17:18:18 -0700 (PDT)


Could anybody on non-Linux platforms run this and tell Avva and I the
output?

#include <stdio.h>
int main (void) {
  int i;
  int max = 0;
  for ( i = 0 ; i < 4096 ; i++ ) {
    void *foo = (void *) malloc((unsigned int) (1 << 20) * i);
    if (foo) {
      max = i;
      free(foo);
    } else {
      printf("max alloc = %d M\n", max);
      exit(0);
    }
  }
  exit(0);
}


We're hoping to avoid fragmenting objects, if we can get a large,
contiguous region from libc.

Let us know your platform in your email.  (BSD, OSX, etc...)

Thanks!
Brad