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
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 ;)
The difference between 'SZ' and 'RSS' is pages that are either shared memory
or swapped out to disk.
--
Valdis Kletnieks
Computer Systems Senior Engineer
Virginia Tech
Attachment:
pgpcx65zD9aos.pgp
Description: PGP signature