|Re: QueuableWeakCacheKey growing endlessly [message #811672 is a reply to message #811455]
||Fri, 02 March 2012 17:15
| Chris Delahunt
Registered: July 2009
My guess is this is a result of the way the application is using EntityManagers and holding onto them without ever clearing them. The property "eclipselink.persistence-context.reference-mode=WEAK" is what is responsible for the QueueableWeakCacheKey being used; the other properties refer to the shared cache settings. This setting does not mean you should use multiple EntityManager instances and hold onto them forever without clearing them; They still have overhead, and from the problem description, you should be clearing or releasing them occassionally. |
From the snap shot, there are twice as many CacheKeyReference as there are QueueableWeakCacheKey, so it looks like your application is reusing EntityManager contexts, but must also be doing alot of batch reads that bring in large numbers of entities. reference-mode=WEAK creates a cache that can expand to fill available memory. Because clean up is expensive, it uses a threshold value that it checks against the current size to determine if it should go through and remove QueueableWeakCacheKey that have had their weak references GCd. This only occurs when a new object is added to the cache, and to prevent it from occuring repeatedly when there are no QueueableWeakCacheKey to clean up, it will increase the threshold to match the size if the size is larger when done. This is a problem for your application because once this is increased, there is no process to decrease the threshold value. So even though the entities themselves eventually get garbage collected, the cache will still hold QueueableWeakCacheKey for those references for the life of the EntityManager (or until it is cleared).
You will need to evaluate how you are holding onto the EntityManagers and how they are being reused to see if you can clear them at appropriate points, or have larger bulk transactions use one that can be released when done.
Powered by FUDForum
. Page generated in 0.02321 seconds