Procházet zdrojové kódy

解决两处内存泄漏,忘记调用Dispose方法了

tanghai před 9 roky
rodič
revize
64d1aa5001

+ 1 - 1
Unity/Assets/Plugins/Base/Network/TNet/TService.cs

@@ -38,7 +38,7 @@ namespace Base
 				TChannel channel = this.idChannels[id];
 				channel.Dispose();
 			}
-
+			this.acceptor.Dispose();
 			this.poller = null;
 		}
 

+ 4 - 3
Unity/Assets/Plugins/Base/Network/TNet/TSocket.cs

@@ -8,7 +8,7 @@ namespace Base
 	/// <summary>
 	/// 封装Socket,将回调push到主线程处理
 	/// </summary>
-	public class TSocket: IDisposable
+	public sealed class TSocket: IDisposable
 	{
 		private readonly TPoller poller;
 		private Socket socket;
@@ -65,8 +65,9 @@ namespace Base
 				return;
 			}
 			
-			this.socket.Close();
-
+			this.socket.Dispose();
+			this.innArgs.Dispose();
+			this.outArgs.Dispose();
 			this.socket = null;
 		}
 

+ 1 - 1
Unity/Assets/Plugins/Base/Object/ObjectManager.cs

@@ -32,7 +32,7 @@ namespace Base
 		}
 	}
 
-	public class ObjectManager : IDisposable
+	public sealed class ObjectManager : IDisposable
 	{
 		private readonly Dictionary<string, Assembly> assemblies = new Dictionary<string, Assembly>();
 

+ 1 - 1
Unity/Assets/Scripts/Config/ACategory.cs

@@ -57,7 +57,7 @@ namespace Model
 				T t;
 				if (!this.dict.TryGetValue(type, out t))
 				{
-					throw new Exception($"{typeof(T)} 没有找到配置, key: {type}");
+					throw new KeyNotFoundException($"{typeof(T)} 没有找到配置, key: {type}");
 				}
 				return t;
 			}