aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
diff options
context:
space:
mode:
authorMelanie2009-08-06 22:03:20 +0100
committerMelanie2009-08-06 22:03:20 +0100
commit91f6898b26caa8f74533dbd90478cf4103251abe (patch)
tree0ee8d1b94c3f0667d32cbf56043fd021fc8d8b73 /OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
parentMerge branch 'master' of ssh://melanie@opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-91f6898b26caa8f74533dbd90478cf4103251abe.zip
opensim-SC_OLD-91f6898b26caa8f74533dbd90478cf4103251abe.tar.gz
opensim-SC_OLD-91f6898b26caa8f74533dbd90478cf4103251abe.tar.bz2
opensim-SC_OLD-91f6898b26caa8f74533dbd90478cf4103251abe.tar.xz
|From: James J Greensky <jame.j.greensky@intel.com>
|Date: Wed, 5 Aug 2009 09:51:52 -0700 |Subject: [PATCH] Closed two major memory leaks for scripted objects | |Two major memory leaks for the scripted objects were fixed |- One leak had to do with remoting acrossing app domains. When a script and | its controlling agent communicate across an application boundary, it calls | functions on a stub proxy object that then invokes the remote method on | the object in the other app domain. These stub objects (two for each script) | were setup to have infinate lifetimes and were never being garbage collected. |- The second leak was the result of adding a scene object part instance method | to a scene event and never removing it. This cause the event's delegate list | to maintain a link to that object which is then never freed as the scene event | object is never destroyed. Patch applied, please direct feedback to me. Possible issue: Longtime idle scripts like vendors may fail.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs25
1 files changed, 18 insertions, 7 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 8168300..6d62249 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -96,7 +96,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
96 private string m_CurrentState = String.Empty; 96 private string m_CurrentState = String.Empty;
97 private UUID m_RegionID = UUID.Zero; 97 private UUID m_RegionID = UUID.Zero;
98 98
99 //private ISponsor m_ScriptSponsor; 99 private ScriptSponsor m_ScriptSponsor;
100 private bool m_destroyed = false;
100 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> 101 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
101 m_LineMap; 102 m_LineMap;
102 103
@@ -261,12 +262,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
261 Path.GetFileNameWithoutExtension(assembly), 262 Path.GetFileNameWithoutExtension(assembly),
262 "SecondLife.Script"); 263 "SecondLife.Script");
263 264
264 // Add a sponsor to the script 265 m_ScriptSponsor = new ScriptSponsor();
265// ISponsor scriptSponsor = new ScriptSponsor(); 266 ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass);
266// ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as MarshalByRefObject); 267 lease.Register(m_ScriptSponsor);
267// lease.Register(scriptSponsor);
268 //m_ScriptSponsor = scriptSponsor;
269
270 } 268 }
271 catch (Exception) 269 catch (Exception)
272 { 270 {
@@ -449,6 +447,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
449 { 447 {
450 ReleaseControls(); 448 ReleaseControls();
451 AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); 449 AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID);
450
451 m_Script.Close();
452 m_ScriptSponsor.Close();
453 ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass);
454 lease.Unregister(m_ScriptSponsor);
455
456 m_destroyed = true;
452 } 457 }
453 458
454 public void RemoveState() 459 public void RemoveState()
@@ -884,6 +889,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
884 889
885 public void SaveState(string assembly) 890 public void SaveState(string assembly)
886 { 891 {
892
893
887 // If we're currently in an event, just tell it to save upon return 894 // If we're currently in an event, just tell it to save upon return
888 // 895 //
889 if (m_InEvent) 896 if (m_InEvent)
@@ -892,6 +899,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
892 return; 899 return;
893 } 900 }
894 901
902 // Data may not be available as the script has already been destroyed
903 if (m_destroyed == true)
904 return;
905
895 PluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID); 906 PluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID);
896 907
897 string xml = ScriptSerializer.Serialize(this); 908 string xml = ScriptSerializer.Serialize(this);