[ 
https://issues.apache.org/jira/browse/CALCITE-2717?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16704311#comment-16704311
 ] 

Haisheng Yuan edited comment on CALCITE-2717 at 11/30/18 6:19 AM:
------------------------------------------------------------------

We have seen the OOM issue accidentally in our system because the cache is not 
garbage-collected as expected. To avoid this issue, we can specify the cache's 
maximum entry size, which I don't like. We can also change the cache loader to 
return the clone of the key, like this:
{code:java}
CacheBuilder.newBuilder()
    .softValues()
    .build(CacheLoader.from(key -> key.clone()));
{code}
But we have to add clone() method into interface RelTrait.

[~julianhyde] thoughts?


was (Author: hyuan):
We have seen the OOM issue accidentally in our system because the cache is not 
garbage-collected as expected. To avoid this issue, we can specify the cache's 
maximum entry size, which I don't like. We can also change the cache loader to 
return the clone of the key, like this:
{code:java}
CacheBuilder.newBuilder()
    .softValues()
    .build(CacheLoader.from(key -> key.clone()));
{code}
But we have to make RelTrait extend Cloneable interface.

[~julianhyde] thoughts?

> 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)

Reply via email to