Created
December 21, 2011 17:54
-
-
Save jballanc/1506977 to your computer and use it in GitHub Desktop.
Count Objects across GC's
This file contains hidden or 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
| $h = {} | |
| $s = "" | |
| $f = proc do | |
| ObjectSpace.count_objects($h) | |
| $c += $h[:TOTAL] - $h[:FREE] | |
| $s = "" | |
| ObjectSpace.define_finalizer($s, $f) | |
| $s = nil | |
| puts "Total objects allocated: #{$c}, GC Cycles: #{GC.count}" | |
| end | |
| ObjectSpace.define_finalizer($s, $f) | |
| $c = 0 | |
| $s = nil | |
| GC.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment