https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112014-12-19T01:18:37ZRuby Issue Tracking SystemRuby master - Bug #10620: #define_singleton_method keeps object from being garbage collectedhttps://redmine.ruby-lang.org/issues/10620?journal_id=504982014-12-19T01:18:37Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>Try the following infinite loop, I see stable memory usage:</p>
<pre><code>loop do
obj = Object.new
obj.define_singleton_method(:f) { "F" }
end
</code></pre>
<p>Not even multiple calls to GC.start can guarantee an object is<br>
collected, as the current Ruby GC is conservative and not precise.<br>
Precise GC should solve the problem, but that is a lot of work<br>
(and we'd still need a conservative part for 3rd party extensions<br>
for years)</p> Ruby master - Bug #10620: #define_singleton_method keeps object from being garbage collectedhttps://redmine.ruby-lang.org/issues/10620?journal_id=505112014-12-19T15:06:00Zsean@duke.edu (Sean Dilda)
<ul></ul><p>Thanks for the quick response.</p>
<p>I tried your code and saw what you did.. it cleans up the objects, just a lot slower than I expected.<br>
Please feel free to close out this bug. I'd do so, but I'm not seeing the option.</p> Ruby master - Bug #10620: #define_singleton_method keeps object from being garbage collectedhttps://redmine.ruby-lang.org/issues/10620?journal_id=514072015-02-05T08:56:47Zshugo (Shugo Maeda)
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul> Ruby master - Bug #10620: #define_singleton_method keeps object from being garbage collectedhttps://redmine.ruby-lang.org/issues/10620?journal_id=515452015-02-18T07:14:39Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Rejected</i></li></ul>