Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1691399 - [GSS](6.4.z) Remote Naming EJB Invocation is not releasing EJBClientContext after close and leaking memory
Summary: [GSS](6.4.z) Remote Naming EJB Invocation is not releasing EJBClientContext a...
Keywords:
Status: ON_QA
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: EJB
Version: 6.4.21
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: CR1
: EAP 6.4.22
Assignee: Tomas Hofman
QA Contact: Peter Mackay
URL:
Whiteboard:
Depends On:
Blocks: eap6422-payload 1691431
TreeView+ depends on / blocked
 
Reported: 2019-03-21 14:26 UTC by Brad Maxwell
Modified: 2019-04-08 11:09 UTC (History)
4 users (show)

Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)
singleton-timer.jar (deleted)
2019-03-21 14:31 UTC, Brad Maxwell
no flags Details
ejbclient.btm (deleted)
2019-03-21 15:09 UTC, Brad Maxwell
no flags Details

Description Brad Maxwell 2019-03-21 14:26:55 UTC
Remote Naming used to invoke EJB is not releasing EJBClientContext.  remoteNamingContext.close() is resulting in EJBClientContext.close() which closes the connections, but it looks like the EJBClientContext objects are unable to finalize as it appears TCCLEJBClientContextSelectorService is still referencing them.

  private Context getRemoteNamingInitialContext(String host, Integer port, String user, String pass, boolean useEjbContext) throws NamingException {
    Properties env = new Properties();
    env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
    if(useEjbContext) 
      env.put("jboss.naming.client.ejb.context", "true");
    env.put("java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory");
    env.put("java.naming.provider.url", String.format("remote://%s:%d", host, port));
    env.put(Context.SECURITY_PRINCIPAL, user);
    env.put(Context.SECURITY_CREDENTIALS, pass);
    return new InitialContext(env);
  }

    Context ctx = null;
    try {
      ctx = getRemoteNamingInitialContext(host, port, user, pass, true);
      Hello ejb = (Hello) ctx.lookup("singleton-timer/HelloBean!com.jboss.examples.ejb.Hello");
      ejb.hello();
    } catch(Throwable t) {
      t.printStackTrace();
    } finally {
      try {
        if(ctx != null) {
          ctx.close();
          ctx = null;
        }
      } catch(Throwable t) {
        t.printStackTrace();
      }
    }


The EJBClientContexts are all retained in org.jboss.as.ejb3.remote.TCCLEJBClientContextSelectorService's identifiableContexts map:

Class Name                                                                                                              | Ref. Objects | Shallow Heap | Ref. Shallow Heap | Retained Heap
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
org.jboss.threads.JBossThread @ 0x76f2e50d0  EJB default - 9 Thread                                                     |        6,405 |          128 |           512,400 |         9,152
'- contextClassLoader org.jboss.modules.ModuleClassLoader @ 0x76e819c60                                                 |        6,405 |           88 |           512,400 |       137,496
   '- classes java.util.Vector @ 0x76ec1d098                                                                            |        6,405 |           32 |           512,400 |       112,352
      '- elementData java.lang.Object[640] @ 0x76f3cb800                                                                |        6,405 |        2,576 |           512,400 |       112,320
         '- [160] class org.jboss.as.ejb3.remote.DefaultEJBClientContextSelector @ 0x76eed97d8                          |        6,405 |           16 |           512,400 |           312
            '- INSTANCE org.jboss.as.ejb3.remote.DefaultEJBClientContextSelector @ 0x76eed9848                          |        6,405 |           24 |           512,400 |            24
               |- tcclEJBClientContextService org.jboss.as.ejb3.remote.TCCLEJBClientContextSelectorService @ 0x76ef8ba50|        6,404 |           24 |           512,320 |     2,308,232
               |  '- identifiableContexts java.util.concurrent.ConcurrentHashMap @ 0x76ef8bb18                          |        6,404 |           64 |           512,320 |     2,307,992
               |     '- table java.util.concurrent.ConcurrentHashMap$Node[16384] @ 0x7bd508000                          |        6,404 |       65,552 |           512,320 |     2,307,928
               |        |- [3054] java.util.concurrent.ConcurrentHashMap$Node @ 0x770900950                             |            5 |           32 |               400 |         1,752
               |        |  |  |- val org.jboss.ejb.client.EJBClientContext @ 0x76fec29f8                                |            1 |           80 |                80 |         2,816
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


So finalize not possible yet.  The remove from this map not occurring upon close like it should?

Comment 1 Brad Maxwell 2019-03-21 14:31:55 UTC
Created attachment 1546523 [details]
singleton-timer.jar

Comment 4 Tomas Hofman 2019-03-21 15:04:09 UTC
EJBClientContext.close() method stack trace:

at org.jboss.ejb.client.EJBClientContext.close(EJBClientContext.java:1317)
	  - locked <0x1fbf> (a org.jboss.ejb.client.EJBClientContext)
	  at org.jboss.naming.remote.client.ejb.RemoteNamingStoreEJBClientHandler$RemoteNamingEJBClientContextCloseTask.close(RemoteNamingStoreEJBClientHandler.java:123)
	  at org.jboss.naming.remote.client.RemoteContext.close(RemoteContext.java:290)
	  at javax.naming.InitialContext.close(InitialContext.java:556)
	  at javax.naming.InitialContext.close(InitialContext.java:556)
	  at com.jboss.examples.ee6.ejb.EE6ExampleSingletonTimer.timeout(EE6ExampleSingletonTimer.java:83)

Comment 5 Brad Maxwell 2019-03-21 15:09:30 UTC
Created attachment 1546573 [details]
ejbclient.btm

Comment 8 Tomas Hofman 2019-03-22 08:20:50 UTC
PR: https://github.com/jbossas/jboss-remote-naming/pull/34


Note You need to log in before you can comment on or make changes to this bug.