mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
PERF: Fix for Memory leak when enabling/disabling a feature
http://orchard.codeplex.com/workitem/16716 --HG-- branch : perf
This commit is contained in:
@@ -81,6 +81,8 @@ namespace Orchard.Tests.Environment {
|
|||||||
_container.Mock<IOrchardShellEvents>()
|
_container.Mock<IOrchardShellEvents>()
|
||||||
.Setup(e => e.Activated());
|
.Setup(e => e.Activated());
|
||||||
|
|
||||||
|
_container.Mock<IOrchardShellEvents>()
|
||||||
|
.Setup(e => e.Terminating()).Callback(() => new object());
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StubExtensionManager : IExtensionManager {
|
public class StubExtensionManager : IExtensionManager {
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Web.Mvc;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Orchard.Caching;
|
using Orchard.Caching;
|
||||||
using Orchard.Environment.Configuration;
|
using Orchard.Environment.Configuration;
|
||||||
@@ -11,10 +10,7 @@ using Orchard.Environment.Descriptor;
|
|||||||
using Orchard.Environment.Descriptor.Models;
|
using Orchard.Environment.Descriptor.Models;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
using Orchard.Mvc;
|
|
||||||
using Orchard.Mvc.ViewEngines;
|
|
||||||
using Orchard.Utility.Extensions;
|
using Orchard.Utility.Extensions;
|
||||||
using Autofac;
|
|
||||||
|
|
||||||
namespace Orchard.Environment {
|
namespace Orchard.Environment {
|
||||||
public class DefaultOrchardHost : IOrchardHost, IShellSettingsManagerEventHandler, IShellDescriptorManagerEventHandler {
|
public class DefaultOrchardHost : IOrchardHost, IShellSettingsManagerEventHandler, IShellDescriptorManagerEventHandler {
|
||||||
@@ -62,7 +58,7 @@ namespace Orchard.Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IOrchardHost.ReloadExtensions() {
|
void IOrchardHost.ReloadExtensions() {
|
||||||
_current = null;
|
DisposeShellContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IOrchardHost.BeginRequest() {
|
void IOrchardHost.BeginRequest() {
|
||||||
@@ -145,11 +141,20 @@ namespace Orchard.Environment {
|
|||||||
ctx => {
|
ctx => {
|
||||||
_extensionLoaderCoordinator.MonitorExtensions(ctx.Monitor);
|
_extensionLoaderCoordinator.MonitorExtensions(ctx.Monitor);
|
||||||
_hostLocalRestart.Monitor(ctx.Monitor);
|
_hostLocalRestart.Monitor(ctx.Monitor);
|
||||||
_current = null;
|
DisposeShellContext();
|
||||||
return "";
|
return "";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DisposeShellContext() {
|
||||||
|
if (_current != null) {
|
||||||
|
foreach (var shellContext in _current) {
|
||||||
|
shellContext.Shell.Terminate();
|
||||||
|
}
|
||||||
|
_current = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void BeginRequest() {
|
protected virtual void BeginRequest() {
|
||||||
MonitorExtensions();
|
MonitorExtensions();
|
||||||
BuildCurrent();
|
BuildCurrent();
|
||||||
@@ -176,11 +181,11 @@ namespace Orchard.Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IShellSettingsManagerEventHandler.Saved(ShellSettings settings) {
|
void IShellSettingsManagerEventHandler.Saved(ShellSettings settings) {
|
||||||
_current = null;
|
DisposeShellContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IShellDescriptorManagerEventHandler.Changed(ShellDescriptor descriptor) {
|
void IShellDescriptorManagerEventHandler.Changed(ShellDescriptor descriptor) {
|
||||||
_current = null;
|
DisposeShellContext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user