umbraco/Umbraco-CMS — pull request #145 by florisrobbemont (2013-10-01 12:13:37+00:00)
Title: U4-3007 RouteDefinition should not store instance of controller

Currently, the route definition class stores an instance of the current controller. This happens in the UmbracoMvcHandler class. However, this controller is only necessary when there's a post to a SurfaceController.

Also, this controller is never released using the ControllerFactory. This creates massive memory leaks overtime as controllers created using a system like Windsor are now never properly released.

To fix this I removed the need to store the instance. The name of controller was already stored in the route definition and I now use that name to create a new instance of the controller when necessary in the UmbracoPageResult class.
The new instance is created using the ControllerFactory and is released properly after the controller has executed.

I will create a pull request with this change. I think this change is backwards compatible because all the changed classes were internal. However, when someone stores stuff inside their controllers (private fields or something) and wants to access them after the post, this will be breaking.