[
https://issues.apache.org/jira/browse/CALCITE-2717?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16705200#comment-16705200
]
Haisheng Yuan commented on CALCITE-2717:
----------------------------------------
If the key and value are pointing to different object, softValues() will work
as expected. But in this case:
{code:java}
CacheBuilder.newBuilder()
.softValues()
.build(CacheLoader.from(key -> key));
{code}
Both key and value point to the same object, with strong key, prevent it from
being garbage collected, even if there is no reference to it outside of the
cache.
I found there is an Interner API in guava, will open a pull request to use
Interner instead.
> Cached traits in RelTraitDef's canonicalMap can't be garbage-collected
> -----------------------------------------------------------------------
>
> Key: CALCITE-2717
> URL: https://issues.apache.org/jira/browse/CALCITE-2717
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Haisheng Yuan
> Assignee: Julian Hyde
> Priority: Major
>
> Softly-referenced objects will be garbage-collected in a globally
> least-recently-used manner, in response to memory demand. Even though
> canonicalMap's value is soft referenced, key is strong referenced, key and
> value are referencing the same object. So traits in the cache will never be
> garbage-collected, which may cause OOM if we have tons of different traits.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)