Reputation: 541
When is an object of a class inside an action of a controller disposed in ASP .NET MVC.?
Upvotes: 1
Views: 135
Reputation: 93444
Unless you explicitly dispose it, then it's disposed whenever the garbage collector runs. There is no way to know when that will happen. That's assuming there is no other reference to the object being stored somewhere.
NOTE: "Dispose" here means to cleanup resources like connections or unmanaged memory. This is done by the object implementing IDisposable.
The object itself will not be deleted from memory (even if disposed) until the garbage collector runs. It is not advisable to try to force garbage collection.
Upvotes: 6