You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using IKernel.Get<T> in a using block, I was having issues with memory leaks as the objects created by IKernel.Get<T> were not being dereferenced and the GC never cleaned them up.
privateIKernelkernel;
...
public T CreateInstance<T>(){using(UnitOfWorkScope.Create())returnthis.kernel.Get<T>();}
The key was assigning the UnitOfWorkScope in the using statement. Even after moving the return outside of the using block, as soon as I removed the var _ = assignment the problem came back.
Not sure what to make of it.
The text was updated successfully, but these errors were encountered:
When using
IKernel.Get<T>
in ausing
block, I was having issues with memory leaks as the objects created byIKernel.Get<T>
were not being dereferenced and the GC never cleaned them up.After refactoring like so, the problem went away:
The key was assigning the UnitOfWorkScope in the using statement. Even after moving the return outside of the using block, as soon as I removed the
var _ =
assignment the problem came back.Not sure what to make of it.
The text was updated successfully, but these errors were encountered: