Re: garbage collection



On Fri, 22 Jun 2001 21:03:07 +0200, Enrico Weigelt <weigelt metux de>  said:
> has anyone thought about integrating an garbage collector 
> in glib/gtk ?

Has anybody thought about the difficulties of implementing a garbage collector
for C, when the user is free to do malloc()/free() and alias pointers to
each other when the GC code isn't in control?

> this would reduce the chance of broken pointers and wasted 
> memory dramatically.

Not really.  Remember that memory would *STILL* get wasted even with a
garbage collector, if there isn't something imposing rules.  If the programmer
doesn't call free(), the memory won't get freed with a garbage collector,
because there will still be a reference (the pointer that wasn't free()ed).

Garbage collectors, in general, really blow major chunks unless you're
coding in a Lisp or Java type language where it's *ENFORCED*.

But that wouldn't be C/C++.
-- 
				Valdis Kletnieks
				Operating Systems Analyst
				Virginia Tech

Attachment: pgps8tpHRLWp5.pgp
Description: PGP signature



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