Re: Memory leaks / Help with memprof & ps output



On Thu, 2002-04-04 at 17:31, Valdis Kletnieks vt edu wrote:
> On Thu, 04 Apr 2002 09:58:45 EST, Jason Tackaberry said:
> 
> >     #include <stdio.h>
> >     #include <glib.h>
> >     
> >     void main() {
> >          char *p = g_new0(char, 1024*1024*100);
> >          g_print("1. Check memory usage...");
> >          getchar();
> >          g_free(p);
> >          g_print("2. Check again...");
> >          getchar();
> >     }
> > 
> > Checking memory usage at (1) shows 100M of RSS, and at (2), shows 600k
> > or so.  Did I misunderstand you?
> 
> That's *RSS* - *RESIDENT* Set Size.  Take a look at the *total* size
> (Linux 2.4 'ps uax' and look at the 'VSZ' column, under Solaris 2.8
> use 'ps -efly' and look at RSS and SZ).  Most malloc() packages are unable
> to use sbrk() to totally return space, and even if they ARE able to, usually
The glibc malloc is also abit smarter, if you allocate large (enough)
chunks of memor in one go, it will use mmap to get that memory, mmap'ed
memory are afaik release back to the os when unmapped..

> there's too much fragmentation of memory to do it without the help
> of a reallocating garbage collector (which is *SO* non-C that I'll not
> discuss it further ;)

-- 
Nils Olav Selåsdal <NOS Utel no>
System Developer, UtelSystems a/s
w w w . u t e l s y s t e m s . c o m





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]