[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
memory fragmentation by the loader
I have the strangest problem.
I have two computers both are with the same HW. Both have 4GB RAM.
Both are installed with FedoraCore3.
I wrote the simplest program that allocates 2GB:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
unsigned long long a = (unsigned long long)2*1024*1024*1024;
fprintf(stderr, "Allocating %llu bytes: ", a);
void *p = malloc(a);
fprintf(stderr, "%p\n", p);
}
And ran it on the two computers. One succeeded to allocate the 2GB, and the
other did not (malloca returned NULL).
I looked at /proc/*/maps and saw that for the computer that succeeded to
allocate the maps were (executable name is a.out):
0056c000-00581000 r-xp 00000000 08:01 1119460 /lib/ld-2.3.3.so
00581000-00582000 r--p 00014000 08:01 1119460 /lib/ld-2.3.3.so
00582000-00583000 rw-p 00015000 08:01 1119460 /lib/ld-2.3.3.so
00585000-006a6000 r-xp 00000000 08:01 1184353 /lib/tls/libc-2.3.3.so
006a6000-006a8000 r--p 00120000 08:01 1184353 /lib/tls/libc-2.3.3.so
006a8000-006aa000 rw-p 00122000 08:01 1184353 /lib/tls/libc-2.3.3.so
006aa000-006ac000 rw-p 006aa000 00:00 0
08048000-08049000 r-xp 00000000 08:01 310089 /root/a.out
08049000-0804a000 rw-p 00000000 08:01 310089 /root/a.out
37ff0000-b7ff3000 rw-p 37ff0000 00:00 0
bffeb000-c0000000 rw-p bffeb000 00:00 0
ffffe000-fffff000 ---p 00000000 00:00 0
Whereas at the machine that did not succeed the maps were:
08048000-08049000 r-xp 00000000 08:01 472530 /root/a.out
08049000-0804a000 rw-p 00000000 08:01 472530 /root/a.out
4f828000-4f83d000 r-xp 00000000 08:01 567954 /lib/ld-2.3.3.so
4f83d000-4f83e000 r--p 00014000 08:01 567954 /lib/ld-2.3.3.so
4f83e000-4f83f000 rw-p 00015000 08:01 567954 /lib/ld-2.3.3.so
4f841000-4f962000 r-xp 00000000 08:01 632747 /lib/tls/libc-2.3.3.so
4f962000-4f964000 r--p 00120000 08:01 632747 /lib/tls/libc-2.3.3.so
4f964000-4f966000 rw-p 00122000 08:01 632747 /lib/tls/libc-2.3.3.so
4f966000-4f968000 rw-p 4f966000 00:00 0
b7e00000-b7e21000 rw-p b7e00000 00:00 0
b7e21000-b7f00000 ---p b7e21000 00:00 0
b7ff1000-b7ff3000 rw-p b7ff1000 00:00 0
bffeb000-c0000000 rw-p bffeb000 00:00 0
ffffe000-fffff000 ---p 00000000 00:00 0
Clearly the decision of the loader (execve() ?) of where to place the dynamic
libraries causes fragmentation thus precludes me from allocating 2G.
How can I convice the loader to load the process file in a more effective way
(like the above example)?
Is it possible from user-space?
Thanks,
Hayim.
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/