【发布时间】:2016-02-12 01:01:19
【问题描述】:
目前在我的应用程序代码中编写如下,我们面临内存泄漏问题
这里的容器保存了所有的图层对象,而不是重新释放它们。
var container = builder.Build()
host.AddDependencyInjectionBehavior(mainInterface, container);
我可以这样写吗,推荐吗
var container = builder.Build()
host.AddDependencyInjectionBehavior(mainInterface,container.BeginLifetimeScope()());
【问题讨论】:
-
@R J:你还没有提出你的问题?
-
感谢您回答 CharithJ。我只想知道在 autofac 网站上,那里写着对于 WCF 与 autofac 的集成,需要编写以下代码。 var container = builder.Build() host.AddDependencyInjectionBehavior(mainInterface, container);我可以通过 container.BeginLifetimeScope() 而不是容器吗?
-
@R J:这两种/任何方法都适合你吗?我猜对你有用的东西应该没问题(不太确定)。在内存泄漏方面,请确保 Dispose LifetimeScope 。
标签: wcf memory-leaks autofac factory-pattern servicehost