* Chasing down memory leak where memory used by a client is not returned on client logout

* This code may or may not be on the right track, but I want to save my work so far.
ThreadPoolClientBranch
Justin Clarke Casey 2008-02-06 20:34:18 +00:00
parent b3e85daf02
commit 548bbc97e5
5 changed files with 50 additions and 10 deletions

View File

@ -68,7 +68,7 @@ namespace OpenSim.Framework
m_clients = new Dictionary<uint, IClientAPI>(); m_clients = new Dictionary<uint, IClientAPI>();
} }
private void Remove(uint id) public void Remove(uint id)
{ {
m_clients.Remove(id); m_clients.Remove(id);
} }

View File

@ -51,6 +51,11 @@ namespace OpenSim.Region.ClientStack
/// </summary> /// </summary>
public class ClientView : IClientAPI public class ClientView : IClientAPI
{ {
~ClientView()
{
m_log.Info("[CLIENTVIEW]: Dstructor called");
}
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/* static variables */ /* static variables */

View File

@ -36,6 +36,9 @@ namespace OpenSim.Region.ClientStack
{ {
public class PacketServer public class PacketServer
{ {
private static readonly log4net.ILog m_log
= log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private ClientStackNetworkHandler m_networkHandler; private ClientStackNetworkHandler m_networkHandler;
private IScene m_scene; private IScene m_scene;
@ -132,8 +135,11 @@ namespace OpenSim.Region.ClientStack
public virtual void CloseClient(IClientAPI client) public virtual void CloseClient(IClientAPI client)
{ {
//m_log.Info("PacketServer:CloseClient()");
CloseCircuit(client.CircuitCode); CloseCircuit(client.CircuitCode);
client.Close(false); client.Close(false);
m_scene.ClientManager.Remove(client.CircuitCode);
} }
} }
} }

View File

@ -97,7 +97,11 @@ namespace OpenSim.Region.Environment.Modules
XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);
Transfers.Add(xferID, transaction); Transfers.Add(xferID, transaction);
NewFiles.Remove(fileName); NewFiles.Remove(fileName);
transaction.StartSend();
if (transaction.StartSend())
{
Transfers.Remove(xferID);
}
} }
} }
} }
@ -107,7 +111,12 @@ namespace OpenSim.Region.Environment.Modules
{ {
if (Transfers.ContainsKey(xferID)) if (Transfers.ContainsKey(xferID))
{ {
Transfers[xferID].AckPacket(packet); if (Transfers[xferID].AckPacket(packet))
{
{
Transfers.Remove(xferID);
}
}
} }
} }
@ -137,7 +146,7 @@ namespace OpenSim.Region.Environment.Modules
public uint Packet = 0; public uint Packet = 0;
public IClientAPI Client; public IClientAPI Client;
public uint Serial = 1; public uint Serial = 1;
private bool complete = false; private bool complete;
public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client)
{ {
@ -151,7 +160,11 @@ namespace OpenSim.Region.Environment.Modules
{ {
} }
public void StartSend() /// <summary>
/// Start a transfer
/// </summary>
/// <returns>True if the transfer is complete, false if not</returns>
public bool StartSend()
{ {
if (Data.Length < 1000) if (Data.Length < 1000)
{ {
@ -160,6 +173,7 @@ namespace OpenSim.Region.Environment.Modules
Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4);
Array.Copy(Data, 0, transferData, 4, Data.Length); Array.Copy(Data, 0, transferData, 4, Data.Length);
Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); Client.SendXferPacket(XferID, 0 + 0x80000000, transferData);
complete = true; complete = true;
} }
else else
@ -171,9 +185,16 @@ namespace OpenSim.Region.Environment.Modules
Packet++; Packet++;
DataPointer = 1000; DataPointer = 1000;
} }
return complete;
} }
public void AckPacket(uint packet) /// <summary>
/// Respond to an ack packet from the client
/// </summary>
/// <param name="packet"></param>
/// <returns>True if the transfer is complete, false otherwise</returns>
public bool AckPacket(uint packet)
{ {
if (!complete) if (!complete)
{ {
@ -193,9 +214,12 @@ namespace OpenSim.Region.Environment.Modules
Client.SendXferPacket(XferID, endPacket, transferData); Client.SendXferPacket(XferID, endPacket, transferData);
Packet++; Packet++;
DataPointer += (Data.Length - DataPointer); DataPointer += (Data.Length - DataPointer);
complete = true; complete = true;
} }
} }
return complete;
} }
} }
} }

View File

@ -39,6 +39,11 @@ namespace OpenSim.Region.Environment.Scenes
{ {
public class ScenePresence : EntityBase public class ScenePresence : EntityBase
{ {
~ScenePresence()
{
m_log.Info("[ScenePresence] Destructor called");
}
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public static AvatarAnimations Animations = new AvatarAnimations(); public static AvatarAnimations Animations = new AvatarAnimations();