Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » ValueHolder eats memory (Using ValueHolder lead to a memory leak)
ValueHolder eats memory [message #522310] Mon, 22 March 2010 09:14 Go to next message
Clementi Ursula is currently offline Clementi Ursula
Messages: 2
Registered: March 2010
Junior Member
Hello

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.

Ursula Clementi

Re: ValueHolder eats memory [message #522504 is a reply to message #522310] Mon, 22 March 2010 20:01 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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
Previous Topic:Migrating Toplink CMP to TopLink/EclipseLink JPA
Next Topic:How to access the object created in a select clause with constructor in an order by?
Goto Forum:
  


Current Time: Thu Sep 18 22:04:30 GMT 2014

Powered by FUDForum. Page generated in 0.02800 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software