|
Re: QueuableWeakCacheKey growing endlessly [message #811672 is a reply to message #811455] |
Fri, 02 March 2012 17:15 |
Chris Delahunt Messages: 1389 Registered: July 2009 |
Senior Member |
|
|
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.
Best Regards,
Chris
|
|
|
|
|
|
Re: QueuableWeakCacheKey growing endlessly [message #1739651 is a reply to message #1739533] |
Wed, 03 August 2016 13:38 |
Chris Delahunt Messages: 1389 Registered: July 2009 |
Senior Member |
|
|
If you are using the EntityManager context as an application cache, maybe you should look into using the shared cache instead. If you are relying on the EntityManager for a cache, using the eclipselink.persistence-context.reference-mode=WEAK setting defeats that purpose, as it allows the GC to remove entities from that cache, forcing it to be re-read in anyway - it is meant to allow garbage collection of large, expensive entities in particular situations and environments. Your application can and should still clear or release the EntityManager context rather than rely on the garbage collection to take care of everything for you, as just setting the eclipselink.persistence-context.reference-mode=WEAK is not a setting that will make memory issues go away.
Feel free to file a feature request to have EclipseLink go through the EntityManager cache and clear out any references to entities that have been garbage collected - I don't quite know how such a feature would work, as having the GC remove these from the cache would cause concurrent modification issues, and having EclipseLink go through the cache at arbitrary points would be a performance drag.
[Updated on: Wed, 03 August 2016 13:41] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04043 seconds