From: Sean O'Dell Date: 2002-02-24T04:01:24+09:00 Subject: Object/Memory Management I'm new to Ruby and the community here (I've been learning Ruby for a grand total of 2 days now), so forgive me if this has already been beaten to death. I have already read a lot of the archives, but I don't know what's being done regarding the garbage collection scheme and the lack of a true object destructor. 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. I sort of understand (just from reading the archived threads on Usenet and the wee bit I found in the pragmatic programmer, developers guide and nutshell) how garbage collection works and why it's there. How hard is it to change it to allow the destruction of individual objects? I think the problem is that, since reference counting sort of screws with some of Ruby's paradigms, it's not practical to do stack-based cleanup. That's fine, I see the advantage of garbage collection. However, what about explicit object destruction? That shouldn't mess with anything. If you can walk the current list of living objects to determine if one can go away, why can't there be a call to explicitly check and destroy one object? Perhaps throw an exception if it can't go away yet, to let the programming know during debugging that he needs to move to call somewhere else. Also, a related issue...why isn't there a finalize call? I don't mean the finalizer where you can set a method to get called after an object is gone, I mean, why isn't there a call to an object's "def finalize...end" right *before* an object goes away? Is that in the works or is that just not the Ruby way? I don't fully understand why explicit object destruction doesn't exist and why there is no object finalize call. Is it against Ruby philosophy and will never be there, or is it just that Ruby is still young and it hasn't been implemented yet? Sean