Castle Longtond Singleton型工厂注射

时间:2011-07-14 15:22:26

标签: .net castle-windsor

我最近正在尝试调试我正在处理的应用程序(Windows服务)中的内存泄漏,并发现数十万WeakReferences - 已全部死亡。跟踪它后,似乎这些是由温莎TypedFactory创建的。

我有以下内容:

[Singleton]
public class MySingleton
{
     public MySingleton(Func<MyOtherType> createMyOtherType) { ... } 
}

[Transient]
public class MyOtherType : IDisposable { ... }
经常调用

createMyOtherType(因为MyOtherTypeIDisposableTransient)。似乎每次拨打createMyOtherType时,WeakReference都会创建一个TypedFactory来跟踪该实例。

我猜测这种行为是设计的,但有没有办法让我告诉打字的工厂在WeakReferences的生命周期内清理它MySingleton

0 个答案:

没有答案