|ValueHolder eats memory [message #522310]
||Mon, 22 March 2010 05:14
| Clementi Ursula
Registered: March 2010
we are using Eclipse 1.1.1 and we are using many ValueHolderInterface for example
private ValueHolderInterface p_status = new ValueHolder();
Now we have recognized that our application uses more and more memory after running a while.
Sometime we are running in a OutOfMemoryError.
I analyzed the problem with VisualVM and come the conclusion that from some mapped instances exist about 40000 Instances in the heap even in the cache are only 2000 Objects !
By tracking back i see the that the class UnitOfWorkQueryValueHolder references in the attribut sesson the UnitOfWork and with that all clones made in that transaction and all cached statments !
For earch Objekt wich is read or registered in a transaction a UnitOfWorkQueryValueHolder is created !.
If i commit a transaction the method clearForClose(false), which would clear the maps is never called with the remark.
//uow still could be used for instantiating of ValueHolders after it's released.
I have tested our application with calling clearForClose(true) and the memory remains clean !!!
What can we do ?
Do i have made a mistace in my analyis ?
Our application needs ValueHolder because of performance issues and because of avoiding deadlocks.
On the other hand we can not restart our application daily.
I can update a picture of VisualVM if somebody is interessted in.
Thanks in advance for any comments you might have on this issue.
|Re: ValueHolder eats memory [message #522504 is a reply to message #522310]
||Mon, 22 March 2010 16:01
| James Sutherland
Registered: July 2009
Location: Ottawa, Canada
The UnitOfWork is only cleared if you call clear(), otherwise, the value holders still require the unit of work to maintain object identity if they are instantiated.|
But even if you do not use value holders, holding these object in your app permanently would be a memory leak, as not only the objects, but also everything they reference will be held in memory. What in your app is holding onto these objects, and why? Can you clear the references to them?
Otherwise, you could call clear() on your EntityManager when you are done with it.
EclipseLink also offers a weak reference mode, which may be of interest,
http://www.eclipse.org/eclipselink/api/2.0.1/org/eclipse/per sistence/config/PersistenceUnitProperties.html#PERSISTENCE_C ONTEXT_REFERENCE_MODE
James : Wiki : Book : Blog : Twitter
Powered by FUDForum
. Page generated in 0.01508 seconds