|Re: QueuableWeakCacheKey growing endlessly [message #811672 is a reply to message #811455]
||Fri, 02 March 2012 12: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.
|Re: QueuableWeakCacheKey growing endlessly [message #812255 is a reply to message #812063]
||Sat, 03 March 2012 08:45
| Manpreet Singh
Registered: December 2010
Will add some more pertinent information about the application and why closing/clearing the EM is not a valid option.|
During Startup we load some entities into memory using JPA.
These object are inserted into a rule engine's memory and kept there.
The rule engine processes incoming messages.
When one or more our objects are affected by the rule engine..
The rule engine calls methods of these objects to make changes including adding or changing cascading objects..
Sometimes these method calls can cause JPA to load some cascaded data using lazy loading
Finally these objects are persisted.
Once we do a batch size of say 500 messages, we issue a commit.
then go back to processing the next batch of incoming messages.
If we close or clear the first instance of the EM (that was created at startup) all the objects added in the rule engine memory will be gone and then we will have to start a new one just before starting to process a new batch of incoming messages.
Now when the rules touch one of the loaded objects, will they need to be attached to the EM ? if so how ?
How will eclipselink know these objects ? Will it remember that it had loaded them from the previous EM ?
This is our issue.
Powered by FUDForum
. Page generated in 0.01862 seconds