This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

memory allocation magic numbers in glibc


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]