-
-
Save eregon/bf86d335fdc9a36d96c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ri --no-pager ObjectSpace | |
ObjectSpace | |
(from ruby core) | |
------------------------------------------------------------------------------ | |
The objspace library | |
The objspace library extends the ObjectSpace module and adds several methods | |
to get internal statistic information about object/memory management. | |
You need to require 'objspace' to use this extension module. | |
Generally, you *SHOULD NOT* use this library if you do not know about the MRI | |
implementation. Mainly, this library is for (memory) profiler developers and | |
MRI developers who need to know about MRI memory usage. | |
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 = "A" | |
b = "B" | |
ObjectSpace.define_finalizer(a, proc {|id| puts "Finalizer one on #{id}" }) | |
ObjectSpace.define_finalizer(b, proc {|id| puts "Finalizer two on #{id}" }) | |
produces: | |
Finalizer two on 537763470 | |
Finalizer one on 537763480 | |
------------------------------------------------------------------------------ | |
Class methods: | |
_id2ref | |
allocation_class_path | |
allocation_generation | |
allocation_method_id | |
allocation_sourcefile | |
allocation_sourceline | |
count_nodes | |
count_objects | |
count_objects_size | |
count_tdata_objects | |
define_finalizer | |
each_object | |
garbage_collect | |
memsize_of | |
memsize_of_all | |
reachable_objects_from | |
trace_object_allocations | |
undefine_finalizer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment