You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ftpserver-users@mina.apache.org by JhuneRGeronimo <jh...@yahoo.com> on 2008/09/01 06:59:41 UTC

Test using Mina

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/Question-regarding-Upward-mobility-for-Mina-and-SLF4j-with-Apache-FTP-Server.-tp13490641p19248923.html
Sent from the FTPServer - Development mailing list archive at Nabble.com.


Re: Test using Mina

Posted by Niklas Gustavsson <ni...@protocol7.com>.
On Mon, Sep 1, 2008 at 6:59 AM, JhuneRGeronimo <jh...@yahoo.com> wrote:
> 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.

You probably meant to send this to users@mina.apache.org. This list is
only for FtpServer related questions.

/niklas