Re: Memory leaks / Help with memprof & ps output



On Tue, 09 Apr 2002 04:58:23 +0200, Enrico Weigelt <weigelt metux de>  said:

> since we're again at the point talking about memleaks,
> whats about using an garbage collector in glib ?

And you'd get a garbage collector to work in C *how*?

Remember - you can't collect garbage if it still has a reference to
it - and in C you can take an address and stash it in a pointer
variable.  How does glib know if I've still got a pointer to something
or not?

int *b, **c;   /* global variable */

int foo()
{
    int *a;
    a = malloc(100*(sizeof int));
    b = a;
    c = malloc(sizeof (int *));
    *c = b;
    /* Garbage collect *that* ;)     */
}

-- 
				Valdis Kletnieks
				Computer Systems Senior Engineer
				Virginia Tech

Attachment: pgpS5QQXvPYYK.pgp
Description: PGP signature



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