Watch out for memory leaks with EhCache

Andrus Adamchik <[email protected]>
Newsgroups gmane.comp.java.cayenne.user
Message-ID <[email protected]>
Hi,

Wanted to mention a scenario when cache misconfiguration can lead to a hard-to-detect memory leak. More details are available in this Jira [1], but the short story is that when you are using JCache/EhCache, make sure that *all* the cache groups used in queries are *explicitly* configured with desired size limits in ehcache.xml [2], including an entry for a no-cache group scenario that corresponds to "cayenne.default.cache" cache name. 

Andrus

[1] https://issues.apache.org/jira/browse/CAY-2642

[2] <config
        xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
        xmlns='http://www.ehcache.org/v3'
        xsi:schemaLocation="
        http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.0.xsd">

    <!-- Used by Cayenne for queries without explicit cache groups. -->
    <cache alias="cayenne.default.cache">
        <expiry>
            <ttl unit="minutes">1</ttl>
        </expiry>
        <heap>100</heap>
    </cache>

    <cache alias="my-cache-group">
        <expiry>
            <ttl unit="minutes">1</ttl>
        </expiry>
        <heap>10</heap>
    </cache>
</config>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.