Memory leak?
neilmcc Feb 4, 2002 4:49 AMHi,
I've been wrestling with an apparent memory leak problem for the past few days. I've got jBoss 2.4.4 running on RH6.2 with 512Mb (physical) RAM on a AMD 300Mhz box. The application I'm deploying has about 15 beans - a mix of BMP entities, stateful session beans and a single MDB listening to JMS (JbossMQ). The beans are accessed by a set of 25 standalone Tomcat 3.2.3 JSP's binding to the beans using the Orion Server ejb tags.
It seems that repeated client/JSP access causes memory usage to steadily grow and grow to the point where ultimately MQ reports EOF stream exceptions and jBoss and Tomcat throw an OutOfMemoryException.
I've seen posts elsewhere suggesting that the JVM may be the main problem - I've tried Sun JDK1.3.0_02, 1.3.1_02 (with/without Hostpot in classic/server mode) plus IBM's 1.3 JVM. Regardless of JVM, the mem leak still appears (though the IBM JVM seems to use even more memory than the Sun variant). With the Sun JVM, JBoss seems to create a new thread for each bean accessed. Switching to green threads hides this issue (at least when looking at ps output) but mem issues still seem to be there.
I've been through the JSP/servlets ensuring there aren't any large objects hanging around in HttpSessions etc. Have also reviewed EJB code to ensure all database connections are being correctly returned to the pool etc. I've also adapted the cache sizes (downwards) in standardjboss.xml in the hope that the beans get persisted quicker - but no luck there.
It's possible the ejb tags are holding onto Jboss beans longer than they need to - this is the main tag code :
protected EJBHome getEjbHome() throws JspException {
try {
InitialContext context = getContext(ejbHost);
// Get the home interface class using the proper (the page's) ClassLoader.
Class homeClass = Class.forName(remoteHome, true, pageContext.getPage().getClass().getClassLoader());
// Lookup the home object
Object homeObject = context.lookup(beanName);
// Narrow it
EJBHome home = (EJBHome)javax.rmi.PortableRemoteObject.narrow(homeObject, homeClass);
return home;
} catch(NamingException e) {
throw new JspException("Error looking up home at " + this.beanName + " for EJB host " + ejbHost + " - " + e.getMessage());
}
catch(ClassNotFoundException e) {
throw new JspException("Home class not found: " + this.remoteHome);
}
}
public int doStartTag() throws JspException {
// Put the variable into the PageContext
EJBHome home = getEjbHome();
pageContext.setAttribute(this.getId(), home);
return SKIP_BODY;
}
Has anyone any thoughts how I might go about debugging/resolving this? It's a big issue for us. Has anyone else manage to successfully deploy JBoss on RH6.2 with any of the JVM's above?
Any suggestions really welcome!
Thanks.