views:

622

answers:

1

Once a controller object is created when does it become available for garbage collection?

+3  A: 

Usually when no active reference to this object is detected. This is handled internally by the garbage collector and so you do not have to take care about it.

So, having this in mind, after the moment Page_Unload method is called which is hosting the controller, the garbage collector gets notified that the controller object is ready for disposal.

Greco
The part about not having active *references* is not really true at all. The CLR uses *reachability* to determine the need garbage collection, not reference counting. See Raymond Chen's blog for details: http://blogs.msdn.com/b/oldnewthing/archive/2010/08/10/10048149.aspx
Eilon