aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common
diff options
context:
space:
mode:
authorTedd Hansen2007-08-25 15:31:47 +0000
committerTedd Hansen2007-08-25 15:31:47 +0000
commit53be4774b32f6736373c1364c3bd659c977fbb4e (patch)
treec81bbc0d41b375bcc403c574da612d18b038c228 /OpenSim/Region/ScriptEngine/Common
parentHopefully fixed the bugs in primitives rotation editing (diff)
downloadopensim-SC-53be4774b32f6736373c1364c3bd659c977fbb4e.zip
opensim-SC-53be4774b32f6736373c1364c3bd659c977fbb4e.tar.gz
opensim-SC-53be4774b32f6736373c1364c3bd659c977fbb4e.tar.bz2
opensim-SC-53be4774b32f6736373c1364c3bd659c977fbb4e.tar.xz
Scripts no longer crash sim after 5 minutes (override InitializeLifetimeService). Loading/Unloading of scripts are now handled in separate thread so server is no delayed because of this. Each script is loaded into a single AppDomain (temporary test for script unload, eats ~15KB more memory for each script). Unload of scripts has been verified to free up memory.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/Executor.cs43
1 files changed, 24 insertions, 19 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs
index 148ae0f..cadd55c 100644
--- a/OpenSim/Region/ScriptEngine/Common/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs
@@ -2,34 +2,40 @@ using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using System.Reflection; 4using System.Reflection;
5using System.Runtime.Remoting.Lifetime;
5 6
6namespace OpenSim.Region.ScriptEngine.Common 7namespace OpenSim.Region.ScriptEngine.Common
7{ 8{
8 public class Executor : MarshalByRefObject 9 public class Executor : MarshalByRefObject
9 { 10 {
10 /* TODO: 11 // Private instance for each script
11 *
12 * Needs to be common for all AppDomains - share memory too?
13 * Needs to have an instance in each AppDomain, and some way of referring it.
14 * Need to know what AppDomain a script is in so we know where to find our instance.
15 *
16 */
17 12
18 private IScript m_Script; 13 private IScript m_Script;
19 private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>(); 14 private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>();
20 private bool m_Running = true; 15 private bool m_Running = true;
21 16 //private List<IScript> Scripts = new List<IScript>();
22 17
23 public Executor(IScript Script) 18 public Executor(IScript Script)
24 { 19 {
25 m_Script = Script; 20 m_Script = Script;
26
27 } 21 }
28 22
29 public void StopScript() 23 // Object never expires
24 public override Object InitializeLifetimeService()
30 { 25 {
31 m_Running = false; 26 Console.WriteLine("Executor: InitializeLifetimeService()");
27 // return null;
28 ILease lease = (ILease)base.InitializeLifetimeService();
29
30 if (lease.CurrentState == LeaseState.Initial)
31 {
32 lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1);
33// lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
34// lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
35 }
36 return lease;
32 } 37 }
38
33 public AppDomain GetAppDomain() 39 public AppDomain GetAppDomain()
34 { 40 {
35 return AppDomain.CurrentDomain; 41 return AppDomain.CurrentDomain;
@@ -40,14 +46,6 @@ namespace OpenSim.Region.ScriptEngine.Common
40 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. 46 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
41 // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! 47 // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
42 48
43 //foreach (MemberInfo mi in this.GetType().GetMembers())
44 //{
45 //if (mi.ToString().ToLower().Contains("default"))
46 //{
47 // Console.WriteLine("Member found: " + mi.ToString());
48 //}
49 //}
50
51 if (m_Running == false) 49 if (m_Running == false)
52 { 50 {
53 // Script is inactive, do not execute! 51 // Script is inactive, do not execute!
@@ -97,6 +95,13 @@ namespace OpenSim.Region.ScriptEngine.Common
97 } 95 }
98 } 96 }
99 97
98
99 public void StopScript()
100 {
101 m_Running = false;
102 }
103
104
100 } 105 }
101 106
102} 107}