Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-4120

Remote EJB2 BMP Memory Leak

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 8.0.13
    • 8.0.14
    • TomEE Core Server
    • None
    • I am using apache-tomee-plus-8.0.13 under windows 10 and jdk 8.

    Description

      I'm seeing a significant memory leak when loading ejb2 bmps remotely. I've found that any ejb2 bmp finder function has a leak on on the client side. The problem eventually causes 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 "BMPTestHome:1" as the key and a HashSet of WeakReferences as values. Attaching screenshot of the eclipse memory profiler which continues to grow the longer the program runs (memoryleak.png).

      package test;
      
      import javax.naming.InitialContext;
      
      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();
      		BMPTestHome bmpTestHome = (BMPTestHome)ctx.lookup("BMPTestHome");
      
      		while (!Thread.currentThread().isInterrupted()) {
      			bmpTestHome.findByPrimaryKey(new BMPTestPK(1));
      			Thread.sleep(5);
      		}
      	}
      }
      

      Attachments

        1. mem1.png
          17 kB
          Thomas Lien
        2. mem2.png
          16 kB
          Thomas Lien
        3. mem3.png
          17 kB
          Thomas Lien
        4. test.ear.zip
          4 kB
          Thomas Lien
        5. memoryleak.png
          18 kB
          Thomas Lien
        6. testjar-src.zip
          3 kB
          Thomas Lien

        Issue Links

          Activity

            People

              tlien Thomas Lien
              tlien Thomas Lien
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h