PERF: Fix for Memory leak when enabling/disabling a feature

http://orchard.codeplex.com/workitem/16716

--HG--
branch : perf
This commit is contained in:
Suha Can
2010-11-04 14:49:12 -07:00
parent d0cb69b805
commit 035c60fb90
2 changed files with 15 additions and 8 deletions

View File

@@ -81,6 +81,8 @@ namespace Orchard.Tests.Environment {
_container.Mock<IOrchardShellEvents>()
.Setup(e => e.Activated());
_container.Mock<IOrchardShellEvents>()
.Setup(e => e.Terminating()).Callback(() => new object());
}
public class StubExtensionManager : IExtensionManager {

View File

@@ -1,6 +1,5 @@
using System.Linq;
using System.Threading;
using System.Web.Mvc;
using System.Collections.Generic;
using Orchard.Caching;
using Orchard.Environment.Configuration;
@@ -11,10 +10,7 @@ using Orchard.Environment.Descriptor;
using Orchard.Environment.Descriptor.Models;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Mvc;
using Orchard.Mvc.ViewEngines;
using Orchard.Utility.Extensions;
using Autofac;
namespace Orchard.Environment {
public class DefaultOrchardHost : IOrchardHost, IShellSettingsManagerEventHandler, IShellDescriptorManagerEventHandler {
@@ -62,7 +58,7 @@ namespace Orchard.Environment {
}
void IOrchardHost.ReloadExtensions() {
_current = null;
DisposeShellContext();
}
void IOrchardHost.BeginRequest() {
@@ -145,11 +141,20 @@ namespace Orchard.Environment {
ctx => {
_extensionLoaderCoordinator.MonitorExtensions(ctx.Monitor);
_hostLocalRestart.Monitor(ctx.Monitor);
_current = null;
DisposeShellContext();
return "";
});
}
private void DisposeShellContext() {
if (_current != null) {
foreach (var shellContext in _current) {
shellContext.Shell.Terminate();
}
_current = null;
}
}
protected virtual void BeginRequest() {
MonitorExtensions();
BuildCurrent();
@@ -176,11 +181,11 @@ namespace Orchard.Environment {
}
void IShellSettingsManagerEventHandler.Saved(ShellSettings settings) {
_current = null;
DisposeShellContext();
}
void IShellDescriptorManagerEventHandler.Changed(ShellDescriptor descriptor) {
_current = null;
DisposeShellContext();
}
}
}