Ruby-doc has this description:
The ObjectSpace module contains a number of routines that interact with the garbage collection facility and allow you to traverse all living objects with an iterator.
ObjectSpace also provides support for object finalizers, procs that will be called when a specific object is about to be destroyed by garbage collection.
Can anyone explain this in a simpler language, if not, atleast provide info on where this is used?
Definition of object space : the space in relation to an optical system in which are located the objects to be imaged by the system — compare image space.
The ObjectSpace module contains a number of routines that interact with the garbage collection facility and allow you to traverse all living objects with an iterator. ObjectSpace also provides support for object finalizers, procs that will be called when a specific object is about to be destroyed by garbage collection.
A garbage collector is a construct in languages with managed memory. It is the thing that manages the memory. Essentially, it's the job of the garbage collector to figure out when a piece of memory that has been allocated is no longer needed, and deallocate it.
When you're using a language with a garbage collector, there are certain things you might want to do:
ObjectSpace gives you access to do things of this nature. Essentially, it's a way to get access to anything and everything that's currently using allocated memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With