[rspec-users] (Bad) Memory Leak in RSpec 2

Kane Baccigalupi lists at ruby-forum.com
Mon Feb 14 17:20:42 EST 2011

David Chelimsky wrote in post #981651:

I am happy to get back to you about the documentation a little later. I
want to take the time to fully describe the problems we had.

> Please let me know what is not yet documented on the following pages:
> http://relishapp.com/rspec/rspec-core/v/2-5/file/upgrade
> http://relishapp.com/rspec/rspec-expectations/v/2-5/file/upgrade
> http://relishapp.com/rspec/rspec-mocks/v/2-5/file/upgrade
> http://relishapp.com/rspec/rspec-rails/v/2-5/file/upgrade
>>    puts Johnson.evaluate <<-JS
>>      Johnson.runtime.gc(); // trying to cleanup via JS
>>    JS
>>  end
>> We have tried a lot of ordering combinations in our garbage collection
>> to see if anything will work, but instead the memory is climbing out of
>> control with each suite. In version RSpec 1.x we didn't have to do any
>> manual garbage collection.
> Nor should you have to. Can you use after(:each) instead of after all?
>   config.after(:each) { @dom = nil }

We set up our @dom in a before :all block and reuse it through out the
file. We don't want to eliminate it after each test, just once per
block/file/whatever we set up.

The problem isn't that the block isn't getting called at the right time.
The problem is that dereferencing the instance variable doesn't seem to
be releasing the variable for garbage collection like it was happening
in version 1.x. We don't know why, and what might be different about
RSpec 2 variable references. More important, we are looking for a good
solution, any solution, to the memory problem.

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list