From: Eric Sven Ristad Date: 2001-03-04T06:18:21+09:00 Subject: [ruby-talk:11947] memory management and object finalization in Ruby Some questions pertaining to memory management in Ruby: 1. How is object finalization handled in Ruby? How can I write a class method that is called when a class instance is destroyed, for example, to close an open file pointer or to clean up some files that the instance has created? 2. What are the limits of Ruby garbage collection? Does the garbage collector close open file pointers in the objects that it reclaims? What types of object finalization is the Ruby programmer responsible for (if any)? 3. How do I profile memory usage in Ruby? I'd like to know (a) how many bytes have been allocated, freed, and remain in use for each class and (b) how many bytes have been allocated inside each class method. I'd also like to determine how many bytes a particular object will return to the pool when it is deallocated by the garbage collector. Is there anyway to track objects as they are reclaimed by the garbage collector, ie., a profilter that would report all objects as they are reclaimed, along with how much memory was reclaimed? Thanks, Eric