Skip to content

Instantly share code, notes, and snippets.

@anveo
Created June 7, 2013 15:41
Show Gist options
  • Save anveo/5730214 to your computer and use it in GitHub Desktop.
Save anveo/5730214 to your computer and use it in GitHub Desktop.
memory leak object reference graph
$ cat app/api/v2/debug.rb
module Api; module V2
class Foobar; end
class Debug < Api::Base
get '/' do
@foobar = Foobar.new
bldr :'debug/index'
end
end
end; end
$ cat app/views/debug/index.bldr
attribute :foobar, 1
# add racksh to Gemfile :devopment and :czar
$ rbenv shell 1.9.3-p392-ref
$ bundle install
$ RACK_ENV=czar bundle exec racksh
$rack.get '/v2/debug'
GC.start
foobar = ObjectSpace.each_object(Api::V2::Foobar).first
require 'object_graph'
ObjectGraph.new(foobar).view!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment