Re: If GC is the solution, then what is the problem?
Seungbeom Kim wrote:
kanze wrote:
Careful. Garbage collection has very little effect on your high
level design. It concerns memory (a very low level resource),
and NOT lifetime of object.
I have to make sure what GC actually means in practice...
Isn't it about not having to explicitly write 'delete' expressions
when you don't need the objects, and GC's automatically taking care of
it? And we all know that 'delete' expressions do two things:
destroying the object by calling the destructor, and releasing the
memory. Then how is it possible that GC does not concern lifetime of
objects?
Garbage collection is about managing memory. If the only reason you are
calling delete is to free the memory (the most frequent case in my
code), then you don't need it. If you are calling it for other reasons
(i.e. the destructor of the object does more than just free memory),
then you need it.
Obviously, this means distinguishing between categories of objects. But
we already have do that anyway, so there's no real additional constraint
here. About the only difference is that with garbage collection, there
is less code to write, and less code to debug.
--
James Kanze kanze.james@neuf.fr
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]