ASP.NET MVC Controllers, Windsor and IDisposable

I recently upgraded one of my larger intranet applications to the latest ASP.NET MVC release and after doing so, I noticed that the memory usage on our webserver would gradually go up and up. After 4-5 hours all the memory on the server was in use (2gb) and the only solution was to restart the application.

After doing some investigation I realised what the problem was: System.Web.Mvc.Controller implements IDisposable and the Windsor IoC container will keep a reference to all transient objects that it creates if they implement IDisposable. So not only was every controller being kept alive, but also everything stored in the ViewData dictionary.

Explicitly calling container.Release() inside the controller factory's DisposeController method fixed the problem.