3
  1. Is there a way to get a list of all currently instantiated objects?

  2. Can that list be made to send an event/message asynchronously whenever it changes?

2
  • 2
    This set of tasks makes me want to cry... I hope it is merely as a debugging/diagnostic aide. Commented Oct 9, 2011 at 19:35
  • for #2, create a new thread in your irb and delegate the watch of your attributes Commented Oct 9, 2011 at 20:11

2 Answers 2

4

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}
Sign up to request clarification or add additional context in comments.

Comments

1

ObjectSpace is your friend; not sure about #2.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.