diff options
author | Melanie | 2009-08-07 03:04:06 +0100 |
---|---|---|
committer | Melanie | 2009-08-07 03:04:06 +0100 |
commit | f8d8366bfa6f048107d22b4b73af22803810be81 (patch) | |
tree | 185a7ccc461a03366e1dade1a6f4ecf5d2c8f4f4 /OpenSim/Region/ScriptEngine/Shared/Api | |
parent | Remove the forge module patch insertion area from prebuild.xml (diff) | |
download | opensim-SC_OLD-f8d8366bfa6f048107d22b4b73af22803810be81.zip opensim-SC_OLD-f8d8366bfa6f048107d22b4b73af22803810be81.tar.gz opensim-SC_OLD-f8d8366bfa6f048107d22b4b73af22803810be81.tar.bz2 opensim-SC_OLD-f8d8366bfa6f048107d22b4b73af22803810be81.tar.xz |
Revert the XEngine memleak patch, it causes premature GC.
This matches behavior seen with an earlier attempt to do this, apparently
the sponsor mechanism does't work in Mono
Diffstat (limited to '')
6 files changed, 41 insertions, 32 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5f9b09b..bc36fda 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -119,15 +119,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
119 | AsyncCommands = new AsyncCommandManager(ScriptEngine); | 119 | AsyncCommands = new AsyncCommandManager(ScriptEngine); |
120 | } | 120 | } |
121 | 121 | ||
122 | // Object never expires | ||
122 | public override Object InitializeLifetimeService() | 123 | public override Object InitializeLifetimeService() |
123 | { | 124 | { |
124 | ILease lease = (ILease)base.InitializeLifetimeService(); | 125 | ILease lease = (ILease)base.InitializeLifetimeService(); |
125 | 126 | ||
126 | if (lease.CurrentState == LeaseState.Initial) | 127 | if (lease.CurrentState == LeaseState.Initial) |
127 | { | 128 | { |
128 | lease.InitialLeaseTime = TimeSpan.FromMinutes(1.0); | 129 | lease.InitialLeaseTime = TimeSpan.Zero; |
129 | lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
130 | lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
131 | } | 130 | } |
132 | return lease; | 131 | return lease; |
133 | } | 132 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b447cfb..7c878b8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -159,15 +159,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | // | ||
163 | // Never expire this object | ||
164 | // | ||
162 | public override Object InitializeLifetimeService() | 165 | public override Object InitializeLifetimeService() |
163 | { | 166 | { |
164 | ILease lease = (ILease)base.InitializeLifetimeService(); | 167 | ILease lease = (ILease)base.InitializeLifetimeService(); |
165 | 168 | ||
166 | if (lease.CurrentState == LeaseState.Initial) | 169 | if (lease.CurrentState == LeaseState.Initial) |
167 | { | 170 | { |
168 | lease.InitialLeaseTime = TimeSpan.FromMinutes(1.0); | 171 | lease.InitialLeaseTime = TimeSpan.Zero; |
169 | lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
170 | lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
171 | } | 172 | } |
172 | return lease; | 173 | return lease; |
173 | } | 174 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 7f67599..2501752 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | |||
@@ -35,7 +35,7 @@ using log4net; | |||
35 | 35 | ||
36 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | 36 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase |
37 | { | 37 | { |
38 | public class Executor | 38 | public class Executor : MarshalByRefObject |
39 | { | 39 | { |
40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
@@ -89,6 +89,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
89 | initEventFlags(); | 89 | initEventFlags(); |
90 | } | 90 | } |
91 | 91 | ||
92 | /// <summary> | ||
93 | /// Make sure our object does not timeout when in AppDomain. (Called by ILease base class) | ||
94 | /// </summary> | ||
95 | /// <returns></returns> | ||
96 | public override Object InitializeLifetimeService() | ||
97 | { | ||
98 | //m_log.Debug("Executor: InitializeLifetimeService()"); | ||
99 | // return null; | ||
100 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
101 | |||
102 | if (lease.CurrentState == LeaseState.Initial) | ||
103 | { | ||
104 | lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); | ||
105 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); | ||
106 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); | ||
107 | } | ||
108 | return lease; | ||
109 | } | ||
110 | |||
111 | |||
92 | public scriptEvents GetStateEventFlags(string state) | 112 | public scriptEvents GetStateEventFlags(string state) |
93 | { | 113 | { |
94 | //m_log.Debug("Get event flags for " + state); | 114 | //m_log.Debug("Get event flags for " + state); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 753ca55..9068634 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -32,7 +32,7 @@ using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | |||
32 | 32 | ||
33 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | 33 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase |
34 | { | 34 | { |
35 | public partial class ScriptBaseClass | 35 | public partial class ScriptBaseClass : MarshalByRefObject |
36 | { | 36 | { |
37 | // LSL CONSTANTS | 37 | // LSL CONSTANTS |
38 | public static readonly LSLInteger TRUE = new LSLInteger(1); | 38 | public static readonly LSLInteger TRUE = new LSLInteger(1); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index d119a77..964fe4c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -26,7 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Runtime.Remoting; | ||
30 | using System.Runtime.Remoting.Lifetime; | 29 | using System.Runtime.Remoting.Lifetime; |
31 | using System.Security.Permissions; | 30 | using System.Security.Permissions; |
32 | using System.Threading; | 31 | using System.Threading; |
@@ -35,23 +34,26 @@ using System.Collections; | |||
35 | using System.Collections.Generic; | 34 | using System.Collections.Generic; |
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 35 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 36 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | ||
39 | 37 | ||
40 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | 38 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase |
41 | { | 39 | { |
42 | public partial class ScriptBaseClass : MarshalByRefObject, IScript | 40 | public partial class ScriptBaseClass : MarshalByRefObject, IScript |
43 | { | 41 | { |
44 | private Dictionary<string, MethodInfo> inits = new Dictionary<string, MethodInfo>(); | 42 | private Dictionary<string, MethodInfo> inits = new Dictionary<string, MethodInfo>(); |
45 | private ScriptSponsor m_sponser; | ||
46 | 43 | ||
44 | // Object expires if we don't keep it alive | ||
45 | // sponsor will be added on object load | ||
46 | [SecurityPermissionAttribute(SecurityAction.Demand, | ||
47 | Flags = SecurityPermissionFlag.Infrastructure)] | ||
47 | public override Object InitializeLifetimeService() | 48 | public override Object InitializeLifetimeService() |
48 | { | 49 | { |
49 | ILease lease = (ILease)base.InitializeLifetimeService(); | 50 | ILease lease = (ILease)base.InitializeLifetimeService(); |
50 | if (lease.CurrentState == LeaseState.Initial) | 51 | if (lease.CurrentState == LeaseState.Initial) |
51 | { | 52 | { |
52 | lease.InitialLeaseTime = TimeSpan.FromMinutes(1.0); | 53 | lease.InitialLeaseTime = TimeSpan.Zero; |
53 | lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | 54 | // lease.InitialLeaseTime = TimeSpan.FromMinutes(1); |
54 | lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | 55 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); |
56 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); | ||
55 | } | 57 | } |
56 | return lease; | 58 | return lease; |
57 | } | 59 | } |
@@ -64,6 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
64 | } | 66 | } |
65 | #endif | 67 | #endif |
66 | 68 | ||
69 | |||
67 | public ScriptBaseClass() | 70 | public ScriptBaseClass() |
68 | { | 71 | { |
69 | m_Executor = new Executor(this); | 72 | m_Executor = new Executor(this); |
@@ -78,8 +81,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
78 | inits[type] = mi; | 81 | inits[type] = mi; |
79 | } | 82 | } |
80 | } | 83 | } |
81 | |||
82 | m_sponser = new ScriptSponsor(); | ||
83 | } | 84 | } |
84 | 85 | ||
85 | private Executor m_Executor = null; | 86 | private Executor m_Executor = null; |
@@ -111,9 +112,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
111 | if (!inits.ContainsKey(api)) | 112 | if (!inits.ContainsKey(api)) |
112 | return; | 113 | return; |
113 | 114 | ||
114 | ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject); | ||
115 | lease.Register(m_sponser); | ||
116 | |||
117 | MethodInfo mi = inits[api]; | 115 | MethodInfo mi = inits[api]; |
118 | 116 | ||
119 | Object[] args = new Object[1]; | 117 | Object[] args = new Object[1]; |
@@ -124,11 +122,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
124 | m_InitialValues = GetVars(); | 122 | m_InitialValues = GetVars(); |
125 | } | 123 | } |
126 | 124 | ||
127 | public void Close() | ||
128 | { | ||
129 | m_sponser.Close(); | ||
130 | } | ||
131 | |||
132 | public Dictionary<string, object> GetVars() | 125 | public Dictionary<string, object> GetVars() |
133 | { | 126 | { |
134 | Dictionary<string, object> vars = new Dictionary<string, object>(); | 127 | Dictionary<string, object> vars = new Dictionary<string, object>(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs index 977ac30..a2da14e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptSponsor.cs | |||
@@ -32,19 +32,15 @@ using System.Text; | |||
32 | 32 | ||
33 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Runtime | 33 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Runtime |
34 | { | 34 | { |
35 | [Serializable] | ||
35 | public class ScriptSponsor : MarshalByRefObject, ISponsor | 36 | public class ScriptSponsor : MarshalByRefObject, ISponsor |
36 | { | 37 | { |
37 | private bool m_closed = false; | 38 | // In theory: I execute, therefore I am. |
38 | 39 | // If GC collects this class then sponsorship will expire | |
39 | public TimeSpan Renewal(ILease lease) | 40 | public TimeSpan Renewal(ILease lease) |
40 | { | 41 | { |
41 | if (!m_closed) | 42 | return TimeSpan.FromMinutes(2); |
42 | return lease.InitialLeaseTime; | ||
43 | return TimeSpan.FromTicks(0); | ||
44 | } | 43 | } |
45 | |||
46 | public void Close() { m_closed = true; } | ||
47 | |||
48 | #if DEBUG | 44 | #if DEBUG |
49 | // For tracing GC while debugging | 45 | // For tracing GC while debugging |
50 | public static bool GCDummy = false; | 46 | public static bool GCDummy = false; |