"Sean Middleditch" <elanthis / awesomeplay.com> wrote in message > I still don't see why you want to delete these objects right away - what > platform are you working on? I can see this in embedded apps or > consoles, but not many other places. I wanted to use Ruby for my hosting system configuration, web site development and also plug it into an XML-over-HTTP application server I wrote/use. Currently, I'm using a blend of script languages and C++, and I want to replace my Perl stuff with something more reliable/readable in terms of being object-oriented and which uses exception-handling. Speed isn't that much of an issue, but memory resources are. Memory gets out of hand quick already, so when I think of all those strings/numbers/objects lying around as zombie objects after I'm done in a block of code, it sort of gets my hair standing up. > Well, it works like this. Ruby has a list of all objects in existance. > When the GC is run, it starts with the base objects (any global > variables/functions/classes/etc.). For each of those objects, it marks > the object as "in use". Then, for each object in use that it finds, it > looks at the object is references. Those objects are marked in use. It > does this until it has scanned every in use object. Then, the sweeper > comes in and destroys any objects that aren't "in use" (not referenced > by any object in use). > > Of course, the GC doesn't work exactly like that, but it's the general > idea (The Ruby website, last I checked, had some links to very technical > discussions on the various types of GC and how they work - Ruby uses a > variation of the Mark and Sweep GC). I'll go look again...I didn't find anything before. So, the way I understand it now, memory objects lay around until the garbage collector checks everything to resolve which objects are used and are not. It doesn't seem like a very efficient way to manage memory, but perhaps I'm missing something...as I said, I'm not very familiar with Ruby, and especially not with its memory managment. I'd like to know more about how it works and what its benefits are. Sean