Scyld: memory leak or just caching?

Mike Weller weller at zyvex.com
Wed Jun 27 14:21:01 PDT 2001


Sean wrote:
> Sounds like just caching to me.  However, if you want to double check,
> write a simple program that malloc()'s about 100M, bpsh it over there
> and see what happens.

Ok, I wrote a program to allocate 100M of RAM.  "ps -leaf" reports
100M used by the program (taking SZ * 4096k/page).  However, "free"
reports an increase of only 100k, and no swap was used.  Does the
kernel preallocate more RAM than it needs, and then gives it to
processes that need it?  How can I learn more about kernel memory?
"ps" is uninformative.

Below is some of the info I captured :

[root at beowulf ~]# cat /home/malloc.c
#include <malloc.h>
#define NUM_MALLOCS 1
int main( )
{
	int x;
	for( x = 0; x < NUM_MALLOCS; ++x )
			malloc( 1024 * 1024 * 100 );
	sleep( 100000 );
	return( 0 );
}

[root at beowulf ~]# bpsh 2 free
      total       used       free     shared    buffers     cached
Mem:       1572388     981924     590464          0     852724      17512
-/+ buffers/cache:     111688    1460700
Swap:      2097136          4    2097132
[root at beowulf ~]# bpsh 2 /home/malloc &
[root at beowulf ~]# bpsh 2 free
             total       used       free     shared    buffers     cached
Mem:       1572388     982032     590356          0     852724      17512
-/+ buffers/cache:     111796    1460592
Swap:      2097136          4    2097132
root       137    15  0 Jul12 ?        00:00:00 ps -eaf
root at beowulf /root # bpsh 2 ps -leaf|egrep "SZ|malloc"
  F S UID        PID  PPID  C PRI  NI ADDR    SZ  WCHAN STIME TTY          TIME CMD
040 T root       136    15  0  70   0    - 25871 109ec7 Jul12 ?        00:00:00 /home/malloc




root at beowulf /root # bpsh 3 free
             total       used       free     shared    buffers     cached
Mem:       1572388     104528    1467860          0      51116      17860
-/+ buffers/cache:      35552    1536836
Swap:      2097136          0    2097136

root at beowulf /root # bpsh 3 /home/malloc &
root at beowulf /root # bpsh 3 free
             total       used       free     shared    buffers     cached
Mem:       1572388     104604    1467784          0      51116      17860
-/+ buffers/cache:      35628    1536760
Swap:      2097136          0    2097136

-- 
Michael J. Weller, M.Sc.               office: (972) 235-7881 x.242
weller at zyvex.com                         cell: (214) 616-6340
Zyvex Corp., 1321 N Plano           facsimile: (972) 235-7882    
Richardson, TX 75081                      icq: 6180540





More information about the Beowulf mailing list