[]

[](p1) Instance Public methods Retrieves a weakly referenced object with the given key

[]=

[]=(p1, p2) Instance Public methods Creates a weak reference from the given key to the given value

_id2ref

ObjectSpace._id2ref(object_id) â an_object Class Public methods Converts an object id to a reference to the object. May not be called on an object id passed as a parameter to a finalizer. s = "I am a string" #=> "I am a string" r = ObjectSpace._id2ref(s.object_id) #=> "I am a string" r == s #=> true

count_objects

ObjectSpace.count_objects([result_hash]) â hash Class Public methods Counts objects for each type. It returns a hash, such as: { :TOTAL=>10000, :FREE=>3011, :T_OBJECT=>6, :T_CLASS=>404, # ... } The contents of the returned hash are implementation specific. It may be changed in future. If the optional argument result_hash is given, it is overwritten and returned. This is intended to avoid probe effect. This method is only expected to work on C Ruby.

define_finalizer

ObjectSpace.define_finalizer(obj, aProc=proc()) Class Public methods Adds aProc as a finalizer, to be called after obj was destroyed.

each_object

ObjectSpace.each_object([module]) {|obj| ... } â fixnumObjectSpace.each_object([module]) â an_enumerator Class Public methods Calls the block once for each living, nonimmediate object in this Ruby process. If module is specified, calls the block for only those classes or modules that match (or are a subclass of) module. Returns the number of objects found. Immediate objects (Fixnums, Symbols true, false, and nil) are never returned. In the example below, each_object r

garbage_collect

GC.start â nilgc.garbage_collect â nilObjectSpace.garbage_collect â nil Class Public methods Initiates garbage collection, unless manually disabled.

undefine_finalizer

ObjectSpace.undefine_finalizer(obj) Class Public methods Removes all finalizers for obj.

add_observer

add_observer(observer, func=:update) Instance Public methods Add observer as an observer on this object. so that it will receive notifications. observer the object that will be notified of changes. func Symbol naming the method that will be called when this Observable has changes. This method must return true for observer.respond_to? and will receive *arg when notify_observers is called, where *arg is the value passed to notify_observers by this Observable

changed

changed(state=true) Instance Public methods Set the changed state of this object. Notifications will be sent only if the changed state is true. state Boolean indicating the changed state of this Observable.