From 4ee8d8a813f6ee164fb361fbf6c26384b668bd1a Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 7 Aug 2009 20:43:23 +0100 Subject: Another stab at cmickeyb's patch for script GC. Moved the Close() for the appdomain-hosted parts into a new destructor on ScriptInstance. --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 8168300..7b6b49f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -96,7 +96,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private string m_CurrentState = String.Empty; private UUID m_RegionID = UUID.Zero; - //private ISponsor m_ScriptSponsor; + private ScriptSponsor m_ScriptSponsor; private Dictionary, KeyValuePair> m_LineMap; @@ -261,12 +261,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance Path.GetFileNameWithoutExtension(assembly), "SecondLife.Script"); - // Add a sponsor to the script -// ISponsor scriptSponsor = new ScriptSponsor(); -// ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as MarshalByRefObject); -// lease.Register(scriptSponsor); - //m_ScriptSponsor = scriptSponsor; - + m_ScriptSponsor = new ScriptSponsor(); + ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); + lease.Register(m_ScriptSponsor); } catch (Exception) { @@ -368,6 +365,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance } } + ~ScriptInstance() + { + m_Script.Close(); + m_ScriptSponsor.Close(); + ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); + lease.Unregister(m_ScriptSponsor); + } + public void Init() { if (!m_startOnInit) return; @@ -884,6 +889,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance public void SaveState(string assembly) { + + // If we're currently in an event, just tell it to save upon return // if (m_InEvent) -- cgit v1.1