Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stateless ejb does not remove the pool

I'm having problems with memory leaks, because EJBs are not being removed from the pool. The ejb is 3.0 and stateless.

In my jboss jmx-console 4.3, the statistics of a particular ejb looks like:

AvailableCount  30
MaxSize     30
CurrentSize     5727
CreateCount     5727
RemoveCount     0

My question is: Why the "Remove Count" is not increasing? And the "Current Size" is larger than the "MaxSize"?

like image 1000
Tiago Braga Avatar asked Aug 17 '12 21:08

Tiago Braga


1 Answers

Man you have hit a dreaded bug where SLSB are not cleared and leaked... We have faced this issue in Our Production environment a couple of weeks ago...

The only workaround even recommended by JBoss is to use StrictMaxPool instead of ThreadLocalPool for your SLSB. Choose the count wisely.

You should modify ejb3-interceptors-aop.xml

<domain name="Stateless Bean">
...
  <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
     @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=30, timeout=10000)
  </annotation>
</domain>

Here are some links to give you some insight...

Stateless session bean pooling in JBoss

New instance of resources injected on every onMessage MDB call

ThreadlocalPool does not remove active BeanContext instances from InfinitePool

like image 145
Bharat Sinha Avatar answered Oct 06 '22 00:10

Bharat Sinha