Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » potential memory leak persisting objects with eclipselink 2
potential memory leak persisting objects with eclipselink 2 [message #539514] Fri, 11 June 2010 07:33 Go to next message
Vadim Gerassimov is currently offline Vadim Gerassimov
Messages: 4
Registered: June 2010
Junior Member
Hello,

maybe my problem mainly is related to glassfish (I posted it there). But ask for advise here too.

The situation is following. I have a JEE6 (using CDI) application packaged as war running on glassfish v3 (3.0.1 b21). I have a stateless bean whose business method is invoked asynchronously:

@Override
@Asynchronous
@Lockable(lockName = HARVEST_XBRL_REPORTS_LOCK_NAME)
@XbrlNextJobFireable
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void harvestData(Long jobId) {

The method loads a lot of data via webservice and persists it to database (Oracle 10.2.05). I noticed that the server eats too many memory and even doesn't free after job execution. I annotated domain objects @Cacheable(false) - without any success. I set eclipselink.cache.size.default to 0 eclipselink.cache.type.default to Weak in persistence.xml - no effect. My application proceeds data by chunks (100 elements) and persists it, after persisting I do flush and even EntityManagerFactory.getCache().evictAll(). I thought that it would help - no success. Only setting eclipselink.cache.type.default to NONE I had some effect. The memory was freed after job execution (not after flushing and evicting the cache). Maybe this is the feature of the transaction - during the transaction no cached object are freed (am I right?).

If I use eclipselink.cache.type.default with other than NONE value, after application undeploy cached objects are still in memory (I discovered it using visualvm). Besides my objectss a lot of UnitOfWorkCacheKey are in memory. No GC doesn't help. Reference keeper of cached objects according the visualvm is some PersistenceObjectInstantiationPolicy.

PS: is it normal eclipselink behavior in transactional environment when eclipselink keeps all objects in memory until transaction completes? Is there any way to overcome such feature?

Thanks,
Vadim

[Updated on: Fri, 11 June 2010 08:43]

Report message to a moderator

Re: potential memory leak persisting objects with eclipselink 2 [message #539665 is a reply to message #539514] Fri, 11 June 2010 18:20 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1034
Registered: July 2009
Senior Member
Hello,

I'm not sure exactly what is going on, but yes, the EntityManager must keep a handle on managed objects while it is within a transaction if that is what you are asking. Accessing the EntityManagerFactory.getCache().evictAll() will evict them from the L2 cache (I believe) where as the transactional cache is within the EntityManager itself. You could try em.clear() after a flush, but EclipseLink will still keep a handle on the changes so it may not help that much.

The simplest guaranteed solution would be to break this transaction up into smaller chunks, much as you are attempting with the flush.

Best Regards,
Chris
Re: potential memory leak persisting objects with eclipselink 2 [message #539819 is a reply to message #539665] Sun, 13 June 2010 17:42 Go to previous message
Vadim Gerassimov is currently offline Vadim Gerassimov
Messages: 4
Registered: June 2010
Junior Member
Yeah, I decided to redesign the application by splitting the big transaction into smaller ones.
Previous Topic:NullPointerException with nested fetch join and multiselect
Next Topic:Auditing for Oracle with EclipseLink JPA
Goto Forum:
  


Current Time: Thu Oct 23 13:46:17 GMT 2014

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

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