0

I've eclipselink v 2.5 enabled application running on Wildfly 8.1 the problem I've noticed is the memory increasing after starting the application because there are huge number of instances of the following classes (snapshot of Visaul VM):

org.eclipse.persistence.internal.identitymaps.HardCacheWeakIdentityMap$ReferenceCacheKey 13083824 13,083,824 (3.1%) 125,806 (1.4%) org.eclipse.persistence.internal.helper.linkedlist.LinkedNode 3020376 3,020,376 (0.6%) 125,849 (1.1%) org.eclipse.persistence.indirection.IndirectList 916608 916,608 (0.3%) 14,322 (0.2%)

When I manually start GC no change happen for these classes and it continue to increase the total number of instances.

here is an EJB as a sample from my code which shows the way I'm using to access the persistence context:

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

import com.sh.entities.Groups;


@Stateless
public class GroupsFacade extends AbstractFacade<Groups> {

    @PersistenceContext(unitName = "WebApplication3PU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public GroupsFacade() {
        super(Groups.class);
    }

    public Groups getByGroupName(String name) {
        TypedQuery<Groups> query = getEntityManager().createNamedQuery("Groups.findByGroupName", Groups.class);

        query.setParameter("groupName", name);
        return query.getSingleResult();
    }

Do any one know where is the problem and why this happens ?

thanks.

A. Shaheen
  • 105
  • 13
  • IndirectList are usually held by your entity objects, while the others have to do with caching. You will need to look at your application and see if it is holding onto entities and the EclipseLink cache settings - these objects themselves aren't necessarily causing problems, it could just be the way you are using your application requires more in the way of memory resources. – Chris Sep 03 '14 at 15:11
  • Hello Chris, I'm using EJB which has a context manager reference using Injection. I've disabled the cache using this tag inside persistense.xml ENABLE_SELECTIVE but I still have the memory issue. – A. Shaheen Sep 04 '14 at 08:22
  • I've updated the topic to include on class used for access the persistence unit – A. Shaheen Sep 04 '14 at 08:50
  • Are you holding onto entities for instance? They would have references to IndirectList and other EclipseLink objects, which in turn reference the context they were read from, which in turn references the EntityManager L1 cache. Everything managed by the EM is held until clear is called, so you might try calling em.clear(). You really should check how these objects are being held and not garbage collected though- I believe you'll find something in your app is holding them indirectly. – Chris Sep 04 '14 at 13:57
  • Thanks Chris, I'll try to clear cache in @PreDestroy annotated method inside my EJB and check again, really thanks for your help – A. Shaheen Sep 04 '14 at 19:06
  • After I've updated my wildfly version to 8.2.1 this issue disappeared I don't know if it was an issue in WELD implementation or JPA implementation . – A. Shaheen Oct 28 '15 at 18:44
  • Did you ever found out why? – cocorossello Jul 02 '21 at 12:39

0 Answers0