Greetings,
I'm trying to tune my Ehcache settings to deal with an issue of running out of old gen heap space. The current setup is MemoryStore only (overflowToDisk=false), Hibernate 3.3.1, and Ehcache 1.7.2.
According to
Hibernate: Truly Understanding the Second-Level and Query Caches, "The first thing to realize about the second-level cache is that it doesn't cache instances of the object type being cached; instead it caches the individual values for the properties of that object." While I see all the individual properties in a heap dump of our app under the net.sf.ehcache.store.MemoryStore for each net.sf.ehcache.Cache, I'm also seeing that they each contain an org.hibernate.cache.CacheKey for each entity, and each of those holds on to a reference to the actual entity instance as its 'key' property. The CacheKey reference seemingly prevents the entire instance graph from ever being GC'd (unless a given key is pushed out of the cache of course). This is accounting for a majority share of my retained heap, and seems to coincide with my old gen "memory leak".
My question is could I be configuring something incorrectly that the CacheKey's are holding references to all my actual entity instances (as opposed to their Long id's or something), or is that how it's intended to work?
Thanks,
Ian