https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112011-10-04T15:53:07ZRuby Issue Tracking SystemRuby master - Feature #5392: Symbol GChttps://bugs.ruby-lang.org/issues/5392?journal_id=211332011-10-04T15:53:07Zrkh (Konstantin Haase)me@rkh.im
<ul></ul><p>How would you ensure identity? Do a search on every Symbol creation? Keep a hash map?</p>
<p>On Oct 3, 2011, at 09:41 , Kurt Stephens wrote:</p>
<blockquote>
<p>Issue <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Symbol GC (Closed)" href="https://bugs.ruby-lang.org/issues/5392">#5392</a> has been reported by Kurt Stephens.</p>
<hr>
<p>Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Symbol GC (Closed)" href="https://bugs.ruby-lang.org/issues/5392">#5392</a>: Symbol GC<br>
<a href="http://redmine.ruby-lang.org/issues/5392" class="external">http://redmine.ruby-lang.org/issues/5392</a></p>
<p>Author: Kurt Stephens<br>
Status: Open<br>
Priority: Normal<br>
Assignee:<br>
Category:<br>
Target version:</p>
<p>I looked more into Symbol GC. The biggest problem is IDs are not VALUEs. My outburst at RubyConf based on my stupid assumption that they were -- I was trying to attack the problem using WeakRefs.</p>
<p>If IDs were VALUEs and Symbols were allocated like any other Object, the existing GC mark and root machinery (including C stack root scans), would take care of it, with an additional sweep of the global_symbol lookup tables.</p>
<p>However, the remaining issue is IDs stored in globals. No matter what, IDs stored in C globals will need to be rb_gc_register_address(VALUE*) roots -- this means CRuby API/contract changes.</p>
<p>Adding a standalone ID mark table and a rb_gc_mark_id() function will not fix problem of lone IDs on the C stack.</p>
<p>What was the original reason to distinguish Symbol IDs from Object VALUEs, besides making lexer tokens simple to map.<br>
Would changing IDs to be allocated VALUE objects simplify internals anyway? This change could also allow Anonymous Symbols and Anonymous Methods.</p>
<p>-- Kurt Stephens</p>
<p>--<br>
<a href="http://redmine.ruby-lang.org" class="external">http://redmine.ruby-lang.org</a></p>
</blockquote> Ruby master - Feature #5392: Symbol GChttps://bugs.ruby-lang.org/issues/5392?journal_id=211522011-10-05T01:05:08Zkstephens (Kurt Stephens)
<ul></ul><p>Konstantin Haase wrote:</p>
<blockquote>
<p>How would you ensure identity? Do a search on every Symbol creation? Keep a hash map?</p>
</blockquote>
<p>Unless I misunderstand your question, we would insure identity with the same mechanism that exists now: a String->Symbol hash map. The difference is the hash map is pruned of dead Symbols during GC sweep. If available, WeakRefs and RefQueues would reduce the cost.</p> Ruby master - Feature #5392: Symbol GChttps://bugs.ruby-lang.org/issues/5392?journal_id=252222012-03-27T03:32:33Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>authorNari (Narihiro Nakamura)</i></li></ul> Ruby master - Feature #5392: Symbol GChttps://bugs.ruby-lang.org/issues/5392?journal_id=332542012-11-20T21:51:02Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Target version</strong> set to <i>2.6</i></li></ul> Ruby master - Feature #5392: Symbol GChttps://bugs.ruby-lang.org/issues/5392?journal_id=430572013-11-21T21:48:41ZauthorNari (Narihiro Nakamura)authorNari@gmail.com
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>duplicated <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Let symbols be garbage collected (Closed)" href="https://bugs.ruby-lang.org/issues/7791">#7791</a></p>