开发者

Unity Container Memory Leaks

Hi I´m working on a project that uses Enterprice Libraries´s Unity container to resolve dependencies for exception handling, cache, logging and db access but we keep getting a lot of leaked objects into memory.

We are using property injection like this:

[Dependency]
public Database DB
{
  get { return db; }
  set { db = value; }
}
[Dependency]
public ExceptionManager ExceptionMgr
{
  get { return exceptionManager; }
  set { exceptionManager = value; }
}

Some of the object leaked:

Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSetti Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings

Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionPolicyData

Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ReplaceHandlerData

Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.WrapHandlerData Microsoft.Practices.EnterpriseLibrary.Common.Configuration.GenericEnumeratorWrapper Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerData 开发者_StackOverflow Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings

Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheStorageData

Any general advice on handling dependencies with Unity to avoid object leaks?


All the objects you list are part of the configuration system. How are you initializing your container? Just calling "AddNewExtension()?" If so, it's not really a leak, since those objects represent the configuration you loaded. The configuration source (which is what's holding on to those objects) stays around for the life of the app so that it can watch for, and notify you, of changes in your application.

What tools are you running that are telling you they're leaking? And are the leaks growing, or constant? Some details would help narrow down the behavior from "expected" to "whoops actual bug".

Also, this is more an Enterprise Library question than a Unity one - Unity itself doesn't leak that I know of.


Are you disposing the Database instance properly? Like for example (using db = new Database()) { .... } ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜