Controllers don't seemed to be released at the end of a request

Controllers seem to be leaked in 1.2.6 but not in 2.0.2. I created an empty rails app with nothing but the following controller:

class HomeController < ApplicationController   def index     @contents =     1.upto(2000) {       @contents << "big long string."     }   end end

where "big long string is about 1K long. This creates a controller with a member variable with a good 2 megs worth of stuff hanging off it. (@contents) If I run this controller in 1.2.6, and then exercise the app, it leaks like a sieve, but in 2.0.2 it doesn't. I was wondering what is hanging onto controllers at the end of a request? I can work around the issue by setting @contents to nil or an empty array at the end of the template but that seems like a hack and the app is still leaking controllers.

Does anyone know what changed in 2.0.2 so that controllers can be collected?

Sigh. I think Im wrong about this. I added a finalizer using ObjectSpace.define_finalizer to the controller where it is created in base.rb. The act of defining the finalizer seems to keep the item from being collected. Sigh. Taking out the define_finalizer seems to fix the issue.

On the other hand something still holding onto my controllers in my full app.

We were investigating something similar recently at the day job, and tracked things back to routing. I'll try and dig up our findings.

~ j.

That would be great. I'll also start looking into routing myself. Thanks for the pointer.