> On Sat, 2002-02-23 at 14:01, Sean O'Dell wrote:
> > Isn't there a way we can *explicitly* destroy objects?  I like to keep
> > things tight and clean in my code, and simply walking away from objects
I've
> > created absolutely freaks me out.  I don't like leaving my program
bloated
> > up in memory with objects that I really only meant to exist for just a
split
> > second while it did something.
>
> You can call the GC routines to do cleanup at any time you want.

Yes, but I'm under the assumption that calling for GC cleanup causes the
entire list of living objects to be checked.  That's not very efficient...I
like objects to go away when I know I'm done with them.

> The reason explicit object destruction can't work is because the
> interpreter has no idea what objects reference the object you are
> destroying.  You could very easily cause dangling pointers, and then a
> crash not too long afterwards.  The best thing to do is, after you are
> sure you want the object destroyed, call the GC routines.  That will
> clean up the object, but *only* if it isn't referenced by anything.

I guess I don't understand how GC works.  I assumed that it walks the entire
list of living objects and gets rid of the ones no longer in use.  It seems
that it would be easier to just check one object rather than every object in
the list.

If the interpreter has no idea what objects reference what, how does garbage
collection work?  How does the garbage collector determine when it's ok to
get rid of an object?

    Sean