From: x1 Date: 2005-12-09T11:13:49+09:00 Subject: Re: Win32OLE: Output parameters, Dispatch IDs ObjectSpace.each_object(Array) do |arr| pid = arr[3] if arr.size == 4 && arr[0, 3] == ["notepad", nil, nil] end --not sure how accurate this would be once 2 or more instances of "notepad" are running simultaneously. On 12/8/05, Dave Burt wrote: > x1 wrote: > > I have not been able to figure anything out yet myself. > > I figured. > > > Do you know off hand how one would be able to find any variable > > names(if exist) that are pointing to a given object? > > Just last week, Joel VanderWerf wrote, in "Re: Memory Leaks: How to see GC > Roots?": > > There's a ruby patch to show what objects are reachable from the roots > > (and the chain of references in each case): > > > > http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/151854?151368-152549 > > > > It should easy to modify it to just show the roots. > > In the same thread, Stephen Kellett posted a link to a product called Ruby > Memory Validator, which lists as a feature "References view. Display the > object reference graph for the application," and the screenshot looks like > it would deal well with this issue. > http://www.softwareverify.com/rubyMemoryValidator/feature.html > > I have not actually operated either of these two possible solutions. > > > For instance when looking at ObjectSpace.cantremembermethodname(Array) > > You get something like: > > ["notepad", nil, nil, 333] > > > > How would one be able to determine the object id and / or any variable > > names associated with it? > > But, it just occurred to me, you could cheat and do something like this to > get the array: > pid = nil > ObjectSpace.each_object(Array) do |arr| > pid = arr[3] if arr.size == 4 && arr[0, 3] == ["notepad", nil, nil] > end > > There you go - recover it from the object pool without knowing where the > references to it are/were. > > Cheers, > Dave > > > >