You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Anil K Patel (Jira)" <ji...@apache.org> on 2026/06/19 11:43:00 UTC

[jira] [Commented] (OFBIZ-4222) UtilCache has memory leak if many temporary caches are created

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

Anil K Patel commented on OFBIZ-4222:
-------------------------------------

This issue is no longer reproducible in current trunk.

The original leak was that AbstractEntityConditionCache created a separate UtilCache per entity condition, each permanently registered in the ConcurrentHashMap UTIL_CACHE_TABLE. With many distinct conditions, the table grew without bound.

The architecture has since been refactored. AbstractEntityConditionCache now extends AbstractCache<EntityCondition, ConcurrentMap<K,V>> — it creates one UtilCache per entity name (a fixed, bounded set), and entity conditions are stored as keys within that single cache. The size of UTIL_CACHE_TABLE is bounded by the number of entity types, not by the number of distinct queries.

Suggesting this issue be marked Resolved / Fixed.

> UtilCache has memory leak if many temporary caches are created
> --------------------------------------------------------------
>
>                 Key: OFBIZ-4222
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4222
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: Trunk, Upcoming Branch
>            Reporter: Philippe Mouawad
>            Assignee: Adam Heath
>            Priority: Major
>              Labels: CACHE, LEAK, MEMORY
>
> Since some time UtilCache has been updated to replace the WeakHashMap by a ConcurrentHashMap:
> private static final ConcurrentHashMap<String, UtilCache<?, ?>> utilCacheTable = new ConcurrentHashMap<String, UtilCache<?, ?>>();
> I think this fix to concurrency issues has introduced a memory leak or at least a much bigger impact on Memory.
> Indeed descendent of AbstractCache (particularly AbstractEntityConditionCache, EntityListCache) tend to create many caches that do not need to always persist in time.
> The old WeakHashMap handled this by enabling them to disappear while today the Hard ref disables this.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)