mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter royal <pro...@apache.org>
Subject Re: Memory leak?
Date Tue, 04 Jul 2006 21:17:34 GMT
On Jul 4, 2006, at 5:59 AM, Michael Bauroth wrote:
> I've attached a method from a simple TCP client, which only writes  
> continously data to a server. Unfortunately over the time the  
> memory consumption increases continously too. I will check the  
> whole thing with JProbe now, but maybe someone has an idea before?!
>
> public void writeProtocol( IoSession pSession, int pCounter )  {
>     ByteBuffer tWriteBuffer = ByteBuffer.wrap(("aaa\r\n" +
> 	"aaa\r\n" +
> 	"aaa\r\n" +
> 	"aaa\r\n" + pCounter + ">\r\n").getBytes());
>     	
>     tWriteBuffer.acquire();
>     pSession.write( tWriteBuffer );
>     tWriteBuffer.release();
> }
>
> When I use ByteBuffer.setUseDirectBuffers( true ), the memory leak  
> occurs, if I use ByteBuffer.setUseDirectBuffers( false ) instead,  
> the app works without memory leak. On the server side (same  
> computer) I use direct buffers all the time!

The acquire() / release() cycle isn't needed in this case, since  
you're wrapping your own byte[].

I'd be interested as to the results of your run with JProbe. I've  
also had very good success tracking down memory leaks using http:// 
yourkit.com profiler.

-pete




-- 
proyal@apache.org - http://fotap.org/~osi




Mime
View raw message