• Bug
  • Status: Closed
  • 1 Critical
  • Resolution: Fixed
  • ehcache-core
  • hsingh
  • Reporter: arauch
  • November 15, 2010
  • 0
  • Watchers: 0
  • January 17, 2013
  • November 23, 2010

Description

Starting in 2.2.0, CacheManager.addCacheNoCheck() adds the new CacheConfiguration to the Configuration map, but nothing (that I can see) ever removes this entry. This (indirectly, see reference path below) creates a permanent hard reference to every cache created, preventing them from being garbage collected. Our application (LabKey Server, www.labkey.org) creates and removes many temporary caches, and this leak makes 2.2.0 and 2.3.0 unusable.

In addition, use of the Configuration.cacheConfigurations map (an ordinary HashMap) doesn’t look thread-safe.

Below is the path from CacheManager to one of our removed caches, copied from jhat:

–> [email protected] (145 bytes) (field configuration) –> [email protected] (114 bytes) (field cacheConfigurations) –> [email protected] (64 bytes) (field table) –> [Ljava.util.HashMap$Entry;@0xf1d1340 (528 bytes) (Element 2 of [Ljava.util.HashMap$Entry;@0xf1d1340) –> [email protected] (44 bytes) (field value) –> [email protected] (217 bytes) (field listeners) –> [email protected] (24 bytes) (field al) –> [email protected] (32 bytes) (field array) –> [Ljava.lang.Object;@0xf55a098 (24 bytes) (Element 0 of [Ljava.lang.Object;@0xf55a098) –> [email protected] (92 bytes) (field primary) –> net.sf.[email protected]0xf55a1a8 (68 bytes) (field eventService) –> [email protected] (80 bytes) (field cache) –> [email protected] (187 bytes)

Comments

Fiona OShea 2010-11-29

Fix in branch ehcache-core-2.3.x and ehcache-core/trunk

Himadri Singh 2010-12-15

CacheManagerTest covers the issue