Geronimo wrote: > > Hi, > > I had run this simple code below for 2 hours and look what happen... Is > there anybody explain and help me why a simple test like this will hit the > memory. > > my Server : > > public class Server2 { > > > public static void main(String[] args) throws IOException { > > > ByteBuffer.setUseDirectBuffers(false); > ByteBuffer.setAllocator(new SimpleByteBufferAllocator()); > > > int PORT = 8999; > IoAcceptor acceptor = new SocketAcceptor(2, > Executors.newCachedThreadPool()); > > IoServiceConfig cfg = acceptor.getDefaultConfig(); > TextLineCodecFactory factory = new > TextLineCodecFactory(Charset.forName("UTF-8")); > factory.setDecoderMaxLineLength(2048); > > cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(factory)); > acceptor.bind(new InetSocketAddress(PORT), new ioHandler(), cfg); > > } > } > > > my Handler > > public class ioHandler extends IoHandlerAdapter { > public void exceptionCaught(IoSession session, Throwable t) throws > Exception { > t.printStackTrace(); > session.close(); > } > > public void messageReceived(IoSession session, Object msg) throws > Exception { > String str = msg.toString(); > if( str.trim().equalsIgnoreCase("quit") ) { > session.close(); > return; > } > Date date = new Date(); > Thread.sleep(840); > for(int i = 0 ;i<1000000; i++ ){ > Thread.sleep(100); > session.write("\n > <action>01</action><action>01</action><action>01</action><action>01</action><action>01</action><action>01</action><action>01</action><action>01</action><action>01</action><action>01</action><action>01</action><action>01</action> > " + i + "\n" ); > } > > WriteFuture sw = session.write( date.toString() ); > > System.out.println("Message written..."); > } > > public void sessionCreated(IoSession session) throws Exception { > System.out.println("Session created..."); > > if( session.getTransportType() == TransportType.SOCKET ) > ((SocketSessionConfig) session.getConfig() > ).setReceiveBufferSize( 2048 > ); > > session.setIdleTime( IdleStatus.BOTH_IDLE, 10 ); > } > } > > > result for 2 HOURS... > > http://www.nabble.com/file/p19248923/mina.jpg >
-- View this message in context: http://www.nabble.com/MINA-tp1936663p19270605.html Sent from the Apache Directory Project mailing list archive at Nabble.com.