outOfMemoryError
Willi Schönborn
schoenborn at cosmocode.de
Wed Jan 5 04:34:09 EST 2011
On 05/01/11 09:17, isagol wrote:
> Hi everyone. First of all . i should thanks everyone.
> Netty is very powerfull and this user group very helpfull to solve problems.
> :)
>
> my problem about java memeory heap. when i run project. i got a result like
> this.
>
> Exception in thread "pool-2-thread-1" java.lang.OutOfMemoryError: Java heap
> space
> at java.util.regex.Matcher.<init>(Unknown Source)
> at java.util.regex.Pattern.matcher(Unknown Source)
> at
> org.jboss.netty.util.internal.StackTraceSimplifier.simplify(StackTraceSimplifier.java:80)
> at
> org.jboss.netty.logging.InternalLoggerFactory$1.warn(InternalLoggerFactory.java:132)
> at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:236)
> at
> org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
> at
> org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
>
> there is one client and one server. Client sends an integer to server
> continuesly. and Server recieves these messages and append a dynamic
> ChannelBuffer. Ofcourse there is a limit of heap. But i think its not about
> the heap size. i am printing the buffer size when messages recieved and its
> changable. Not a constant value.
>
> i am sending messages in client messageRecieved method.
> @Override
> public void messageReceived(ChannelHandlerContext ctx, final MessageEvent
> e) {
>
> ChannelBuffer buf = buffer(4);
> buf.writeInt(123412341);
>
According to
http://docs.jboss.org/netty/3.2/xref/org/jboss/netty/example/discard/package-summary.html
i think the next line should read
while (e.getChannel().isWriteable()) {
> while (true) {
>
> e.getChannel().write(buf);
>
> }
>
> }
>
> in server side. i am recieving messages
>
> static public ChannelBuffer dataBuffer;
> private ChannelBuffer buf;
>
>
> public ServerHandler() {
> dataBuffer = ChannelBuffers.dynamicBuffer();
> }
>
> @Override
> public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
>
> Channel channel = e.getChannel();
>
> buf = (ChannelBuffer) e.getMessage();
> dataBuffer.writeBytes(buf.toByteBuffer());
> buf.clear();
> System.out.println("size: " + dataBuffer.toByteBuffer().limit());
>
> }
>
> Thanks in Advance...
>
--
Willi Schoenborn / Software Development
__ CosmoCode GmbH - http://www.cosmocode.de
__ Prenzlauer Allee 36, 10405 Berlin, Germany
__ Tel +49 30 814504087, Fax +49 30 28097093
__
__ Geschaeftsfuehrung (CEO): D. Huettemann, J. Riebesell
__ Amtsgericht Berlin-Charlottenburg, HRB 74063
More information about the netty-users
mailing list