Easily Repeatable: java.lang.OutOfMemoryError: Java heap space

"Eric Crampton" <[email protected]>
Newsgroups gmane.comp.java.mx4j.user
Message-ID <[email protected]>
Hi all,

I've found it's quite easy to make mx4j run out of heap space when
using the HTTPAdaptor with the XSLTProcessor. I've been able to reduce
it to a single tiny application. Repeatedly hitting the JMX HTTP
interface (say, 300-350 times with a simple script) causes gradually
growing heap size until it runs out of memory. (With the default JVM
arguments for stack and heap, it doesn't take long.)

Here's a simple program to demonstrate:

import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;

import mx4j.tools.adaptor.http.HttpAdaptor;
import mx4j.tools.adaptor.http.XSLTProcessor;

public class Main {
    public static void main(String[] args) throws Exception {
        MBeanServer server = MBeanServerFactory.createMBeanServer();

        XSLTProcessor processor = new XSLTProcessor();
        ObjectName pname = new ObjectName("Server:name=XSLTProcessor");
        server.registerMBean(processor, pname);

        HttpAdaptor adapter = new HttpAdaptor();
        ObjectName name = new ObjectName("Server:name=HttpAdaptor");
        server.registerMBean(adapter, name);
        adapter.setPort(8000);
        adapter.setHost("0.0.0.0");
        adapter.setProcessor(processor);
        adapter.start();

        while (true) {
            System.gc();
            Thread.sleep(1000);
        }
    }
}

I'm running mx4j 3.0.1 on Java 5 SE (Linux):
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)

It doesn't seem to happen when only using HTTPAdaptor *without* the
XSLTProcessor. I also tried using the current nightly snapshot---no
luck.

Any ideas how to fix this? Am I doing something wrong?

Regards,
--Eric

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.