The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Memory Inspector

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Hodel

Posts: 660
Nickname: drbrain
Registered: Mar, 2006

Eric Hodel is a long-time Rubyist and co-founder of Seattle.rb.
Memory Inspector Posted: Aug 30, 2006 2:27 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eric Hodel.
Original Post: Memory Inspector
Feed Title: Segment7
Feed URL: http://blog.segment7.net/articles.rss
Feed Description: Posts about and around Ruby, MetaRuby, ruby2c, ZenTest and work at The Robot Co-op.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eric Hodel
Latest Posts From Segment7

Advertisement

I've hacked into gc.c and added an alternative to ObjectSpace.each_object that gives you the contents of every heap slot in Ruby's memory space.

$ ./ruby -I ~/Work/p4/zss/src/RubyInline/dev/ ~/heapwalk.rb
[id, size, inspect]
0x001aa004 0x00000000                                                    :__free
0x001aa018 0x00000000                                                    :__free
0x001aa02c 0x00000000                                                    :__free
0x001aa040 0x00000000                                                    :__free
[the beginning is boring...]
0x001caa20 0x00000014                                           #<Class:Marshal>
0x001caa34 0x00000014                                                    :__node
0x001caa48 0x00000014                                                    :__node
0x001caa5c 0x0000000c                                                    Marshal
[but there's things like nodes, singleton classes, modules,]
0x001caae8 0x0000000c                #<NoMemoryError: failed to allocate memory>
0x001caafc 0x0000002d                                "failed to allocate memory"
0x001cab10 0x00000014                                                         []
[exceptions, strings, arrays and other objects,]
0x001ce5f8 0x00000014                                                  :__iclass
[included Modules,]
0x001dad30 0x00000014                                                   :__scope
[scopes, and some other stuff that's too hard to find]

It requires a hack to gc.c to gain access to the heap, but combined with Ryan's memory visualizer this might generate something usable.

Code will be available later I've audited my object size calculations (and have slept).

Read: Memory Inspector

Topic: On Writing Well: Exposition or Code Previous Topic   Next Topic Topic: Ruby on Rails: Using Full Text Search with Tagging

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use