README.md in memprof2-0.0.1 vs README.md in memprof2-0.0.2

- old
+ new

@@ -26,57 +26,69 @@ # API ## Memprof2.report - Memprof2.start - 12.times{ "abc" } - Memprof2.report(out: "/path/to/file") - Memprof2.stop +```ruby +Memprof2.start +12.times{ "abc" } +Memprof2.report(out: "/path/to/file") +Memprof2.stop +``` Start tracking file/line memory size (bytes) information for objects created after calling `Memprof2.start`, and print out a summary of file:line:class pairs created. - 480 file.rb:2:String +``` +480 file.rb:2:String +``` *Note*: Call `Memprof2.report` again after `GC.start` to see which objects are cleaned up by the garbage collector: - Memprof2.start - 10.times{ $last_str = "abc" } +```ruby +Memprof2.start +10.times{ $last_str = "abc" } - puts '=== Before GC' - Memprof2.report +puts '=== Before GC' +Memprof2.report - puts '=== After GC' - GC.start - Memprof2.report +puts '=== After GC' +GC.start +Memprof2.report - Memprof2.stop +Memprof2.stop +``` After `GC.start`, only the very last instance of `"abc"` will still exist: - === Before GC - 400 file.rb:2:String - === After GC - 40 file.rb:2:String +``` +=== Before GC +400 file.rb:2:String +=== After GC +40 file.rb:2:String +``` *Note*: Use `Memprof2.report!` to clear out tracking data after printing out results. ## Memprof2.run Simple wrapper for `Memprof2.start/stop` that will start/stop memprof around a given block of ruby code. - Memprof2.run do - 100.times{ "abc" } - 100.times{ 1.23 + 1 } - 100.times{ Module.new } - Memprof2.report(out: "/path/to/file") - end +```ruby +Memprof2.run do + 100.times{ "abc" } + 100.times{ 1.23 + 1 } + 100.times{ Module.new } + Memprof2.report(out: "/path/to/file") +end +``` For the block of ruby code, print out file:line:class pairs for ruby objects created. - 4000 file.rb:2:String - 4000 file.rb:3:Float - 4000 file.rb:4:Module +``` +4000 file.rb:2:String +4000 file.rb:3:Float +4000 file.rb:4:Module +``` *Note*: You can call GC.start at the end of the block to print out only objects that are 'leaking' (i.e. objects that still have inbound references). ## ChangeLog