Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lfittl/objspace_helpers
Diff the heap to find leaks & get other ObjectSpace info more easily.
https://github.com/lfittl/objspace_helpers
Last synced: 21 days ago
JSON representation
Diff the heap to find leaks & get other ObjectSpace info more easily.
- Host: GitHub
- URL: https://github.com/lfittl/objspace_helpers
- Owner: lfittl
- License: bsd-2-clause
- Created: 2014-11-22T05:07:58.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-09T13:44:56.000Z (about 10 years ago)
- Last Synced: 2024-04-25T20:04:29.951Z (8 months ago)
- Language: C
- Size: 160 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
objspace_helpers
================Experimental repository containing helper functions for ObjectSpace in MRI Ruby 2.1+.
This repository uses a hand-crafted C extension which is not advised for production
or even day-by-day development use. It uses private APIs and stuff.Installation
------------```
gem install objspace_helpers
```Usage
-----```ruby
class SampleClass
def initialize
@@my_class_variable = "yay"
end
endtop_level_leaks, leak_sources = ObjspaceHelpers.find_leak_sources(trace: true) do
SampleClass.new'my_symbol'.to_sym
endtop_level_leaks
=> [#]top_level_leaks.first.info
=> {"type"=>"STRING", "class"=>140285594211920, "frozen"=>true, "embedded"=>true, "fstring"=>true, "bytesize"=>9, "value"=>"my_symbol", "encoding"=>"US-ASCII", "references"=>[], "file"=>"(irb)", "line"=>9, "generation"=>21, "method"=>"to_sym", "flags"=>{"wb_protected"=>true, "old"=>true, "marked"=>true}}leak_sources
=> {#=>[#]>]}leak_sources.keys.first.info
=> {"type"=>"CLASS", "class"=>140285597413760, "name"=>"SampleClass", "references"=>[140285597413800, 140285597414440, 140285597415800, 140285595807360, 140285594220400], "memsize"=>672, "flags"=>{"wb_protected"=>true, "old"=>true, "marked"=>true}}leak_sources.values[0][0].info
=> {"type"=>"STRING", "class"=>140285594211920, "embedded"=>true, "bytesize"=>3, "value"=>"yay", "encoding"=>"UTF-8", "references"=>[], "file"=>"(irb)", "line"=>3, "generation"=>21, "method"=>"initialize", "flags"=>{"wb_protected"=>true, "old"=>true, "marked"=>true}}
```Authors
-------- [Lukas Fittl](mailto:[email protected])
License
-------Copyright (c) 2014, Lukas Fittl
objspace_helpers is licensed under the 2-clause BSD license, see LICENSE file for details.