Is there a way to get a list of all currently instantiated objects?
Can that list be made to send an event/message asynchronously whenever it changes?
-
2This set of tasks makes me want to cry... I hope it is merely as a debugging/diagnostic aide.user166390– user1663902011-10-09 19:35:01 +00:00Commented Oct 9, 2011 at 19:35
-
for #2, create a new thread in your irb and delegate the watch of your attributesapneadiving– apneadiving2011-10-09 20:11:38 +00:00Commented Oct 9, 2011 at 20:11
Add a comment
|
2 Answers
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.count_objects
# => {:TOTAL=>56824, :FREE=>7190, :T_OBJECT=>5943, :T_CLASS=>878, :T_MODULE=>35, :T_FLOAT=>7, :T_STRING=>26950, :T_REGEXP=>189, :T_ARRAY=>10224, :T_HASH=>193, :T_STRUCT=>1, :T_BIGNUM=>5, :T_FILE=>7, :T_DATA=>1674, :T_MATCH=>22, :T_COMPLEX=>1, :T_NODE=>3468, :T_ICLASS=>37}