فهرست منبع

BETA: Memory leak fix: Since database connections are autoclosed via try/catch, the L2DatabaseFactory.close(con) is never called. Because of this, a memory leak occured -> the map is always filled with data, but never removed (it gets removed only when L2DatabaseFactory.close(con) is called).

Nik 12 سال پیش
والد
کامیت
eb4a994e15
1فایلهای تغییر یافته به همراه1 افزوده شده و 12 حذف شده
  1. 1 12
      L2J_Server_BETA/java/com/l2jserver/L2DatabaseFactory.java

+ 1 - 12
L2J_Server_BETA/java/com/l2jserver/L2DatabaseFactory.java

@@ -17,16 +17,12 @@ package com.l2jserver;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
-import java.util.Map;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javolution.util.FastMap;
-
 import com.l2jserver.gameserver.ThreadPoolManager;
 import com.mchange.v2.c3p0.ComboPooledDataSource;
 
@@ -48,7 +44,6 @@ public class L2DatabaseFactory
 	
 	private static L2DatabaseFactory _instance;
 	private static volatile ScheduledExecutorService _executor;
-	private static Map<Connection, ScheduledFuture<?>> _connectionClosers = new FastMap<Connection, ScheduledFuture<?>>().shared();
 	private ProviderType _providerType;
 	private ComboPooledDataSource _source;
 	
@@ -271,7 +266,7 @@ public class L2DatabaseFactory
 				con = _source.getConnection();
 				if (Server.serverMode == Server.MODE_GAMESERVER)
 				{
-					_connectionClosers.put(con, ThreadPoolManager.getInstance().scheduleGeneral(new ConnectionCloser(con, new RuntimeException()), Config.CONNECTION_CLOSE_TIME));
+					ThreadPoolManager.getInstance().scheduleGeneral(new ConnectionCloser(con, new RuntimeException()), Config.CONNECTION_CLOSE_TIME);
 				}
 				else
 				{
@@ -343,12 +338,6 @@ public class L2DatabaseFactory
 		try
 		{
 			con.close();
-			ScheduledFuture<?> conCloser = _connectionClosers.remove(con);
-			if (conCloser != null)
-			{
-				conCloser.cancel(true);
-				conCloser = null;
-			}
 		}
 		catch (SQLException e)
 		{