Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is a Transient-scope object Deactivated in Ninject?

When an object in Ninject is bound with InTransientScope(), the object isn't placed into the cache, since it's, er, transient and not scoped to anything.

When done with the object, I can call kernel.Release(obj); this passes through to the Cache where it retrieves the cached item and calls Pipeline.Deactivate using the cached entry.

But since transient objects aren't cached, this doesn't happen. I haven't been able to figure out where (or who) performs the deactivation for transient objects. Or is the assumption that transient objects are only ever activated, and that if I want a deactivateable object, I need to use some other scope?

like image 819
nwahmaet Avatar asked Mar 12 '10 18:03

nwahmaet


1 Answers

Your assumptions are correct. Transient objects are not tracked in Ninject and not controlled in the deactivation pipeline. It is your responsibility to clean up transient instances. If you want the kernel to manage your instances, then you need to use a built-in scope or a custom scope.

like image 160
Ian Davis Avatar answered Nov 02 '22 02:11

Ian Davis