Re: 2GB-Memory-Linux: Strange Behavior

Xintian Wu (xintian@cse.ogi.edu)
Sat, 17 Jan 1998 13:41:13 -0800 (PST)


On Sat, 17 Jan 1998, MOLNAR Ingo wrote:

> i suppose that 'anonymous mmap()'-s fail in this case. This is what is
> used by malloc() and all usual allocators. Now, there is a limit, which is
> not 2GB but:
>
> processor.h:#define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
>
> in your case this is 2G/3=666MB. Which means your system will give at most
> 1.333G memory to the process. [unless i'm missing some libc mechanizms].
> To get more per-process anonymous mappings, simply do the following,
> change include/asm-i386/processor.h:line 82 to:
>
> #define TASK_UNMAPPED_BASE (TASK_SIZE / 8)
>
> this should give 256M space to normal 'file mappings', and ~1700M to
> 'freely allocatable memory'. Do 'cat /proc/1234/maps' to see how your
> program allocates memory.
>

Oops. I get bigger memory when I set TASK_UNMAPPED_BASE to TASK_SIZE/2,
which is equal to 0xc0000000/3. This time, even swap space starts to work.
I think I use normal malloc and mmap.

Here is my map:

08048000-0805a000 r-xp 00000000 08:11 1157156 /usr/home/xintian/prog
0805a000-0805d000 rw-p 00011000 08:11 1157156 /usr/home/xintian/prog
0805d000-36d7b000 rwxp 00000000 00:00 0
40000000-40005000 r-xp 00000000 08:01 16368 /lib/ld-linux.so.1.9.5
40005000-40006000 rw-p 00004000 08:01 16368 /lib/ld-linux.so.1.9.5
40006000-40009000 rw-p 00000000 00:00 0
40009000-40010000 r-xp 00000000 08:01 16370 /lib/libm.so.5.0.9
40010000-40012000 rw-p 00006000 08:01 16370 /lib/libm.so.5.0.9
40012000-40096000 r-xp 00000000 08:01 16364 /lib/libc.so.5.4.38
40096000-4009b000 rw-p 00083000 08:01 16364 /lib/libc.so.5.4.38
4009b000-400ce000 rw-p 00000000 00:00 0
400ce000-4afab000 r--s 00000000 08:04 6147 /usr/home/xintian/mmap1
4afab000-4cb7b000 rw-p 00000000 00:00 0
4cb7b000-4cd66000 rw-p 00000000 08:04 6146 /usr/home/xintian/mmap2
4cd8f000-4d032000 rw-p 00029000 00:00 0
4d032000-4e4ad000 r--s 00000000 08:04 6148 /usr/home/xintian/mmap3
4e4ad000-53e90000 rw-p 00000000 00:00 0
53eae000-54e4c000 rw-p 05a01000 00:00 0
54e60000-57c14000 rw-p 069b3000 00:00 0
7fffd000-80000000 rwxp ffffe000 00:00 0

1:38pm up 1:52h, 2 users, load average: 4.19, 3.81, 3.79
31 processes: 26 sleeping, 5 running, 0 zombie, 0 stopped
CPU states: 377.6% user, 18.8% system, 0.0% nice, 0.0% idle
Mem: 2020188K av, 1866476K used, 153712K free, 109804K shrd, 412K buff
Swap: 130748K av, 316K used, 130432K free 33324K cached

USER PID %CPU %MEM NI VSZ RSS SHRD TT STAT TIME COMMAND
xintian 819 98.9 14.2 0 493M9 281M0 27432 p0 R 10:08 prog
xintian 818 95.1 10.4 0 409M0 207M0 26620 p0 R 9:59 prog
xintian 817 93.7 50.5 0 1199M 997M3 27236 p0 R 10:02 prog
xintian 820 91.5 20.3 0 607M8 400M7 26932 p0 R 9:58 prog
xintian 786 16.9 0.0 0 1480 640 468 p1 R 1:44 /usr/bin/top