diff src/alice/daemon/OutboundTcpConnection.java @ 122:d5d9ca4cbe87 working fish-example-worked

fix memory leak!
author one
date Fri, 27 Jul 2012 02:04:45 +0900
parents b01fb5090e28
children 1044a79ce4ef
line wrap: on
line diff
--- a/src/alice/daemon/OutboundTcpConnection.java	Fri Jul 27 00:46:01 2012 +0900
+++ b/src/alice/daemon/OutboundTcpConnection.java	Fri Jul 27 02:04:45 2012 +0900
@@ -10,6 +10,7 @@
 public class OutboundTcpConnection extends Thread {
 	
 	public Connection connection;
+	private static MessagePack MSGPACK = new MessagePack();
 	
 	public OutboundTcpConnection(Connection connection) {
 		this.connection = connection;
@@ -23,7 +24,6 @@
 	 * pipeline thread for transmission
 	 */
 	public void run() {
-		MessagePack msgpack = new MessagePack();
 		while (true) {
 			try {
 				Command cmd = connection.sendQueue.take();
@@ -38,7 +38,7 @@
 					break;
 				}
 				CommandMessage cmdMsg = convert(cmd);
-				ByteBuffer buffer = ByteBuffer.wrap(msgpack.write(cmdMsg));
+				ByteBuffer buffer = ByteBuffer.wrap(MSGPACK.write(cmdMsg));
 				while (buffer.hasRemaining()) {
 					connection.socket.getChannel().write(buffer);
 				}