This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
memory allocation magic numbers in glibc
- To: libc-alpha at sourceware dot cygnus dot com
- Subject: memory allocation magic numbers in glibc
- From: SL Baur <steve at turbolinux dot co dot jp>
- Date: 01 Sep 2000 21:19:06 +0900
Why does the following program give two different numbers depending
upon how it is invoked?
#include <stdio.h>
main()
{
int i = 0;
char *p;
while (i++ < 5000) {
p = malloc(1024 * 1024);
if (!p) break;
}
printf("allocated %ld kbytes\n", (i-1)*1024L);
}
On Alpha I get:
# /tmp/mtest
allocated 5120000 kbytes
# /lib/ld-linux.so.2 /tmp/mtest
allocated 1048576 kbytes
On Intel I get:
$ /tmp/mtest
allocated 1965056 kbytes
$ /lib/ld-linux.so.2 /tmp/mtest
allocated 1048576 kbytes