You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Thomas Lien (Jira)" <ji...@apache.org> on 2022/12/01 15:48:00 UTC

[jira] [Updated] (TOMEE-4120) Remote EJB2 BMP Memory Leak

     [ https://issues.apache.org/jira/browse/TOMEE-4120?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Lien updated TOMEE-4120:
-------------------------------
    Description: 
I'm seeing a significant memory leak when loading ejb2 bmps remotely. Not including the server side code because it doesn't appear to be particularly relevant since I've found that any ejb2 bmp does the same thing and the leak happens on the client side. The problem eventually causing our client application to crash with an out of memory error.

Below is a simple main function I made to demonstrate. If I run this program below using a single ejb2 findByPrimaryKey call, memory will grow rapidly. I traced it down using the Eclipse Memory Profiler to the org.apache.openejb.client.EJBInvocationHandler class retaining memory in a ConcurrentHashMap field called liveHandleRegistry. I can see it has my SetupHome object as a key and a HashSet as values. Attaching screenshots of the eclipse memory profiler as it continues to grow over a few minutes as the program runs.

import javax.naming.InitialContext;
import alliancetechnical.sm4.ejb.SetupHome;
import alliancetechnical.sm4.ejb.SetupPK;

public class LookupMemTest {

    public static void main(String[] args) throws Exception {
        System.setProperty("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
        System.setProperty("java.naming.provider.url", "http://127.0.0.1:8080/tomee/ejb");
        InitialContext ctx = new InitialContext();
        SetupHome setupHome = (SetupHome)ctx.lookup("SetupHome");

        while (!Thread.currentThread().isInterrupted()) {
            setupHome.findByPrimaryKey(new SetupPK(1));
            Thread.sleep(5);
        }
    }
}

  was:
I'm seeing a significant memory leak when loading ejb2 bmps remotely. Not including the server side code because it doesn't appear to be particularly relevant since I've found that any ejb2 bmp does the same thing and the leak happens on the client side. The problem eventually causing our client application to crash with an out of memory error.

Below is a simple main function I made to demonstrate. If I run this program below using a single ejb2 findByPrimaryKey call, memory will grow rapidly. I traced it down using the Eclipse Memory Profiler to the org.apache.openejb.client.EJBInvocationHandler class retaining memory in a ConcurrentHashMap field called liveHandleRegistry. I can see it has my SetupHome object as a key and a HashSet as values. Attaching screenshots of the eclipse memory profiler as it continues to grow over a few minutes as the program runs.

import java.rmi.RemoteException;
import javax.ejb.FinderException;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import alliancetechnical.sm4.ejb.SetupHome;
import alliancetechnical.sm4.ejb.SetupPK;

public class LookupMemTest {

    public static void main(String[] args) throws RemoteException, FinderException, NamingException {
        System.setProperty("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
        System.setProperty("java.naming.provider.url", "http://127.0.0.1:8080/tomee/ejb");
        InitialContext ctx = new InitialContext();
        SetupHome setupHome = (SetupHome)ctx.lookup("SetupHome");

        while (!Thread.currentThread().isInterrupted()) {
            setupHome.findByPrimaryKey(new SetupPK(1));
            try {
                Thread.sleep(5);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }


    }
}


> Remote EJB2 BMP Memory Leak
> ---------------------------
>
>                 Key: TOMEE-4120
>                 URL: https://issues.apache.org/jira/browse/TOMEE-4120
>             Project: TomEE
>          Issue Type: Bug
>          Components: TomEE Core Server
>    Affects Versions: 8.0.13
>         Environment: I am using apache-tomee-plus-8.0.6 under windows 10 and jdk 8.
>            Reporter: Thomas Lien
>            Priority: Major
>         Attachments: mem1.png, mem2.png, mem3.png
>
>
> I'm seeing a significant memory leak when loading ejb2 bmps remotely. Not including the server side code because it doesn't appear to be particularly relevant since I've found that any ejb2 bmp does the same thing and the leak happens on the client side. The problem eventually causing our client application to crash with an out of memory error.
> Below is a simple main function I made to demonstrate. If I run this program below using a single ejb2 findByPrimaryKey call, memory will grow rapidly. I traced it down using the Eclipse Memory Profiler to the org.apache.openejb.client.EJBInvocationHandler class retaining memory in a ConcurrentHashMap field called liveHandleRegistry. I can see it has my SetupHome object as a key and a HashSet as values. Attaching screenshots of the eclipse memory profiler as it continues to grow over a few minutes as the program runs.
> import javax.naming.InitialContext;
> import alliancetechnical.sm4.ejb.SetupHome;
> import alliancetechnical.sm4.ejb.SetupPK;
> public class LookupMemTest {
>     public static void main(String[] args) throws Exception {
>         System.setProperty("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
>         System.setProperty("java.naming.provider.url", "http://127.0.0.1:8080/tomee/ejb");
>         InitialContext ctx = new InitialContext();
>         SetupHome setupHome = (SetupHome)ctx.lookup("SetupHome");
>         while (!Thread.currentThread().isInterrupted()) {
>             setupHome.findByPrimaryKey(new SetupPK(1));
>             Thread.sleep(5);
>         }
>     }
> }



--
This message was sent by Atlassian Jira
(v8.20.10#820010)