ngallagher / simpleframework

Simple Framework
179 stars 38 forks source link

java.lang.OutOfMemoryError: Direct buffer memory after a certain time (approx. 1 week) #19

Open pierrelucveilleux opened 8 years ago

pierrelucveilleux commented 8 years ago

Did you experiment this error with your test?

Exception in thread "ActionDistributor: Thread-3" java.lang.OutOfMemoryError: Direct buffer memory at java.nio.Bits.reserveMemory(Bits.java:658) at java.nio.DirectByteBuffer.(DirectByteBuffer.java:123) at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311) at org.simpleframework.transport.SocketBufferAppender.(SocketBufferAppender.java:72) at org.simpleframework.transport.SocketBuffer.(SocketBuffer.java:84) at org.simpleframework.transport.SocketBufferWriter.(SocketBufferWriter.java:59) at org.simpleframework.transport.SocketTransport.(SocketTransport.java:125) at org.simpleframework.transport.OperationFactory.getInstance(OperationFactory.java:143) at org.simpleframework.transport.OperationFactory.getInstance(OperationFactory.java:127) at org.simpleframework.transport.TransportSocketProcessor.process(TransportSocketProcessor.java:145) at org.simpleframework.http.core.ContainerSocketProcessor.process(ContainerSocketProcessor.java:143) at org.simpleframework.transport.connect.SocketAcceptor.process(SocketAcceptor.java:297) at org.simpleframework.transport.connect.SocketAcceptor.accept(SocketAcceptor.java:241) at org.simpleframework.transport.connect.SocketAcceptor.run(SocketAcceptor.java:189) at org.simpleframework.transport.reactor.ExecuteAction.run(ExecuteAction.java:72) at org.simpleframework.common.thread.SynchronousExecutor.execute(SynchronousExecutor.java:41) at org.simpleframework.transport.reactor.ActionDistributor.execute(ActionDistributor.java:734) at org.simpleframework.transport.reactor.ActionDistributor.process(ActionDistributor.java:680) at org.simpleframework.transport.reactor.ActionDistributor.process(ActionDistributor.java:653) at org.simpleframework.transport.reactor.ActionDistributor.distribute(ActionDistributor.java:637) at org.simpleframework.transport.reactor.ActionDistributor.execute(ActionDistributor.java:253) at org.simpleframework.transport.reactor.ActionDistributor.run(ActionDistributor.java:233) at org.simpleframework.common.thread.Daemon$RunnableDelegate.run(Daemon.java:156) at java.lang.Thread.run(Thread.java:745)

snapscript commented 8 years ago

You can configure this, this occurs when the client is not reading quickly. It frees the writing thread and allows it to return to the servicing thread pool, allowing a sub-system to continue delivering the payload in the background. See the following to configure.

public TransportSocketProcessor(TransportProcessor processor, int threads, int buffer, int threshold) throws IOException { this(processor, threads, buffer, threshold, false); }

Here threshold represents the maximum size of the output buffer. You can reduce it to something like 1K which should resolve your memory issues.