functional tests leak memory

Bug #251273 reported by Marius Gedminas
2
Affects Status Importance Assigned to Milestone
Zope 3
Fix Released
Undecided
Unassigned

Bug Description

All functional tests in Zope-3-based apps leak memory by keeping references to all in-memory databases created for each test. This was observed with zope.app.testing 3.4.1.

FunctionalTestSetup.setUp() calls multi_database which registers the new database object as a global utility providing IDatabase. The utility registry doesn't automatically remove overriden registrations, it always adds to them.
The object graph keeping the DB objects in memory after running 5 functional tests can be seen at http://mg.pov.lt/db-objects-in-memory.png

The fix is to unregister the IDatabase utilities in FunctionalTestSetup.tearDown(). I'm attaching a tested patch.

Revision history for this message
Marius Gedminas (mgedmin) wrote :
Revision history for this message
Marius Gedminas (mgedmin) wrote :

Some numbers: on an app I've got here with ~250 functional tests, this patch reduces test runner's memory usage from 500 megs down to 110 megs, and reduces the test run time from 29 minutes down to 21 minutes.

Revision history for this message
Marius Gedminas (mgedmin) wrote :

Fix committed in rev 88823.

I'd like to release 3.4.3 with this fix.

Changed in zope3:
status: New → Fix Committed
Revision history for this message
Fred Drake (fdrake) wrote : Re: [Bug 251273] Re: functional tests leak memory

+1 on releasing.

Revision history for this message
Marius Gedminas (mgedmin) wrote :

Fix released in zope.app.testing 3.4.3.

Changed in zope3:
status: Fix Committed → Fix Released
Revision history for this message
Marius Gedminas (mgedmin) wrote :

I'd like to get this into the KGS as well, but apparently I don't have scp access to download.zope.org:/var/www/download.zope.org/zope3.4/controlled-packages.cfg

Revision history for this message
Stephan Richter (srichter) wrote :

On Friday 25 July 2008, Marius Gedminas wrote:
> I'd like to get this into the KGS as well, but apparently I don't have
> scp access to download.zope.org:/var/www/download.zope.org/zope3.4
> /controlled-packages.cfg

Darn. I am back in the office on Monday and will try to debug this with you
and Jim.

Regards,
Stephan
--
Stephan Richter
Web Software Design, Development and Training
Google me. "Zope Stephan Richter"

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.