A few months ago a bug was reported in JRuby where the inline method 
cache was holding a reference to class objects that would normally have 
been garbage collected:

http://jira.codehaus.org/browse/JRUBY-2716

The effect essentially works like this:

- The method object contains a reference to the class in which it was 
defined
- The cache holds a hard reference to the method object, to allow it to 
be quickly invoked later
- If the method's class goes away, the reference chain keeps it alive

On a hunch, I ran the test today against 1.9, since it also employs an 
inline cache. And sure enough, it failed just the same. You can try the 
test (attached to the bug) by removing the require 'java' line and 
replacing java.lang.System.gc with GC.start.

So I have a couple questions:

1. This isn't much of a leak, since it's limited by the number of call 
sites in the system; but it does represent a dangling reference to what 
would otherwise be a dead object. How severe would you consider it?
2. It may be problematic to solve; the inline cache and the method must 
have some knowledge of the original type, because of the way Ruby works. 
Is it possible to fix this? Any ideas?

I've been treating it as a low-priority issue, and I believe the 
original reporter worked around it. But it does seem like a systemic 
problem with inline caching in Ruby. I would expect it to affect 
Rubinius, IronRuby, and Maglev as well.

Other thoughts?

- Charlie