diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs index 3319783..63e1844 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs | |||
@@ -15,7 +15,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
15 | { | 15 | { |
16 | public class AppDomainManager | 16 | public class AppDomainManager |
17 | { | 17 | { |
18 | private int MaxScriptsPerAppDomain = 3; | 18 | private int MaxScriptsPerAppDomain = 1; |
19 | /// <summary> | 19 | /// <summary> |
20 | /// Internal list of all AppDomains | 20 | /// Internal list of all AppDomains |
21 | /// </summary> | 21 | /// </summary> |
@@ -59,7 +59,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
59 | private AppDomainStructure GetFreeAppDomain() | 59 | private AppDomainStructure GetFreeAppDomain() |
60 | { | 60 | { |
61 | Console.WriteLine("Finding free AppDomain"); | 61 | Console.WriteLine("Finding free AppDomain"); |
62 | FreeAppDomains(); // Outsite lock, has its own GetLock | ||
63 | lock (GetLock) | 62 | lock (GetLock) |
64 | { | 63 | { |
65 | // Current full? | 64 | // Current full? |
@@ -111,7 +110,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
111 | /// <summary> | 110 | /// <summary> |
112 | /// Unload appdomains that are full and have only dead scripts | 111 | /// Unload appdomains that are full and have only dead scripts |
113 | /// </summary> | 112 | /// </summary> |
114 | private void FreeAppDomains() | 113 | private void UnloadAppDomains() |
115 | { | 114 | { |
116 | lock (FreeLock) | 115 | lock (FreeLock) |
117 | { | 116 | { |
@@ -125,10 +124,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
125 | // Is number of unloaded bigger or equal to number of loaded? | 124 | // Is number of unloaded bigger or equal to number of loaded? |
126 | if (ads.ScriptsLoaded <= ads.ScriptsWaitingUnload) | 125 | if (ads.ScriptsLoaded <= ads.ScriptsWaitingUnload) |
127 | { | 126 | { |
127 | Console.WriteLine("Found empty AppDomain, unloading"); | ||
128 | // Remove from internal list | 128 | // Remove from internal list |
129 | AppDomains.Remove(ads); | 129 | AppDomains.Remove(ads); |
130 | #if DEBUG | ||
131 | |||
132 | long m = GC.GetTotalMemory(true); | ||
133 | #endif | ||
130 | // Unload | 134 | // Unload |
131 | AppDomain.Unload(ads.CurrentAppDomain); | 135 | AppDomain.Unload(ads.CurrentAppDomain); |
136 | #if DEBUG | ||
137 | Console.WriteLine("AppDomain unload freed " + (m - GC.GetTotalMemory(true)) + " bytes of memory"); | ||
138 | #endif | ||
132 | } | 139 | } |
133 | } | 140 | } |
134 | } // foreach | 141 | } // foreach |
@@ -142,20 +149,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
142 | // Find next available AppDomain to put it in | 149 | // Find next available AppDomain to put it in |
143 | AppDomainStructure FreeAppDomain = GetFreeAppDomain(); | 150 | AppDomainStructure FreeAppDomain = GetFreeAppDomain(); |
144 | 151 | ||
145 | //if (FreeAppDomain == null) Console.WriteLine("FreeAppDomain == null"); | ||
146 | //if (FreeAppDomain.CurrentAppDomain == null) Console.WriteLine("FreeAppDomain.CurrentAppDomain == null"); | ||
147 | Console.WriteLine("Loading into AppDomain: " + FileName); | 152 | Console.WriteLine("Loading into AppDomain: " + FileName); |
148 | LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); | 153 | LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); |
149 | //Type mytype = mbrt.GetType(); | 154 | //Console.WriteLine("ScriptEngine AppDomainManager: is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); |
150 | Console.WriteLine("ScriptEngine AppDomainManager: is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); | ||
151 | |||
152 | // Increase script count in tihs AppDomain | ||
153 | FreeAppDomain.ScriptsLoaded++; | 155 | FreeAppDomain.ScriptsLoaded++; |
154 | 156 | ||
155 | //mbrt.Start(); | ||
156 | return mbrt; | 157 | return mbrt; |
157 | //return (LSL_BaseClass)mbrt; | ||
158 | |||
159 | } | 158 | } |
160 | 159 | ||
161 | 160 | ||
@@ -168,6 +167,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
168 | { | 167 | { |
169 | lock (FreeLock) | 168 | lock (FreeLock) |
170 | { | 169 | { |
170 | Console.WriteLine("Stopping script in AppDomain"); | ||
171 | // Check if it is current AppDomain | 171 | // Check if it is current AppDomain |
172 | if (CurrentAD.CurrentAppDomain == ad) | 172 | if (CurrentAD.CurrentAppDomain == ad) |
173 | { | 173 | { |
@@ -181,15 +181,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
181 | { | 181 | { |
182 | if (ads.CurrentAppDomain == ad) | 182 | if (ads.CurrentAppDomain == ad) |
183 | { | 183 | { |
184 | // Found it - messy code to increase structure | 184 | // Found it |
185 | //AppDomainStructure ads2 = ads; | ||
186 | ads.ScriptsWaitingUnload++; | 185 | ads.ScriptsWaitingUnload++; |
187 | //AppDomains.Remove(ads); | 186 | break; |
188 | //AppDomains.Add(ads2); | ||
189 | return; | ||
190 | } | 187 | } |
191 | } // foreach | 188 | } // foreach |
192 | } // lock | 189 | } // lock |
190 | |||
191 | UnloadAppDomains(); // Outsite lock, has its own GetLock | ||
192 | |||
193 | |||
193 | } | 194 | } |
194 | 195 | ||
195 | 196 | ||