Archived

This forum has been archived. Please start a new discussion on GitHub.

OutOfMemoryError Exception in the client side

Hi,

I have a servlet that connects with an Ice server and implements a basic search page. The servlet works fine with a lot of load (I'm testing with JMeter, with 50 concurrent users per second). Now I'm testing the same functionality with ColdFusion MX (Developers Edition, that it's free :)), and when I run the JMeter test plan during 5 minutes, the Ice ThreadPool launches this exception:

java.lang.OutOfMemoryError
at java.nio.Bits.reserveMemory(Bits.java:618)
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:95)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:285)
at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:54)
at sun.nio.ch.IOUtil.read(IOUtil.java:205)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:207)
at IceInternal.TcpTransceiver.read(TcpTransceiver.java:236)
at Ice.ConnectionI.read(ConnectionI.java:1061)
at IceInternal.ThreadPool.read(ThreadPool.java:898)
at IceInternal.ThreadPool.run(ThreadPool.java:698)
at IceInternal.ThreadPool.access$100(ThreadPool.java:12)
at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:1194)

This is the Java object that all the requests in ColdFusion shares:

public final class Lucene {
private static TCommand tCommand = null;

private Lucene() {}

private static TCommand getTCommand() throws TExecuteException {
if (tCommand==null){
TCommand c;
try {
c = new TCommand("lucene_conf.xml");
} catch (TExecuteException te){
// blablabla exception
}

Lucene.tCommand = c;
}

return Lucene.tCommand;
}

public static final TResultSet search(Map map) throws TExecuteException {
return getTCommand().execute ( "search", map);
}
}

I'm sure that all the threads in ColdFusion shares the same instance of TCommand (the object that connects with the server). In the constructor of TCommand I initialize the Ice.Communicator, and in the execute method I only connect with the remote object. TCommand is used in the servlet that works fine.

The test plan is the same in the Tomcat test and ColdFusion Test. Has Ice some problem with ColdFusion MX? Is my class Lucene? (I have read somewhere that is not a good idea to create threads in a J2EE server, and perhaps ColdFusion crashes with the ThreadPool... I don't know...)

Cheers, and thanks a lot!

Comments

  • It's impossible to say what's going wrong from the context you provided. All I can see is that the JVM is running out of memory. There could be hundreds of reasons for that, quite possibly unrelated to Ice.

    Note that you are getting the exception on the server side because it is thrown by the thread pool in response to an incoming request. The only way for this to happen on the client side would be if the server makes a callback to the client.

    I have no suggestion other than to keep simplifying your server until you end up removing the part that causes the problem. For starters, I would try this with a empty, dummy servant implementation, that is, by disabling as much of the application logic as possible. If the error goes away with that, you know that it's most likely caused by something in the application code. If not, it may be Ice-related.

    Cheers,

    Michi.
  • Hi Michi!

    I'm getting the exception on the client side, not in the server side.

    I removed the Ice application logic, and instead of connecting with Ice server I connect to basic server that connects with MySQL. I didn't have problems with this test.

    Thanks a lot for your time!
  • benoit
    benoit Rennes, France
    Another thing that you could try is to write a simple Ice client that simulates what your servlet is doing and see if you get the OutOfMemoryError exception. But I suspect it will work if it worked with Tomcat... Perhaps you simply need to increase the maximum heap size for the JVM when using Cold Fusion MX?

    Btw, although this is probably not the cause of your issue, I don't see any synchronization for the initialization of the "tCommand" singleton so if multiple threads invoke the getTCommand() method at the same time it's possible that you initialize multiple TCommand object.

    In any case, we're not aware of any incompatibilities between Ice and ColdFusion.

    Benoit.
  • Hi Benoit,

    ok, i'll run a simple Ice client to debug all the process.

    Thank you very much, and happy new year! ;)