Skip to content

Instantly share code, notes, and snippets.

@abimaelmartell
Last active June 15, 2016 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abimaelmartell/c4c659e56a962c01d5825981f6526e2e to your computer and use it in GitHub Desktop.
Save abimaelmartell/c4c659e56a962c01d5825981f6526e2e to your computer and use it in GitHub Desktop.
Debug a memory leak, or a hanging process on a rails application.

Attach the process to a gdb session.

sudo gdb $(rbenv which ruby) $(pgrep thin)

Enter this on the gdb prompt.

set $ary = (int)backtrace(-1)
set $count = *($ary+8)
set $index = 0
while $index < $count
  x/1s *((int)rb_ary_entry($ary, $index)+12)
  set $index = $index + 1
end

You will see the output at the console running the thin command.

Taken from http://weblog.jamisbuck.org/2006/9/22/inspecting-a-live-ruby-process.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment