TestCase instances may not be collected till selftest finishes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Fix Released
|
Medium
|
Martin Packman |
Bug Description
<https:/
>> The old TestCase.run had this finally code, is there an equivalent in testtools?
>>
>> saved_attrs = {}
>> for attr_name in self.attrs_to_keep:
>> if attr_name in self.__dict__:
>> saved_attrs[
>> self.__dict__ = saved_attrs
>
> That code is replaced by discarding tests that have been run, a much
> simpler way of freeing memory.
This turns out to not actually be true in a number of importance cases. The upshot of which is up to 200% higher peak memory usage, with associated longer runtime, and symptoms like bug 392127 and other OOM related test failures.
<https:/
Has some specific measurements on memory usage.
So, why aren't the TestCase instances collected after being run, as planned?
* There's cycle created by testtools between the TestCase and the ContentType containing the log
* In Python 2.7 there are bound methods assert<Type>Equal stored on the instance _type_equality_
* Likely other test-specific cycles especially with the existing resource leaks
* TestDecorator classes with __iter__ methods keep test list copies
* ...more?
The cycles at least will get GCed, but evidently there are enough things surviving till the run completes to waste hundreds of megabytes of memory and cause spurious failures on my box.
Given that even if this is fixed, it will be hard not to accidentally introduce regressions by leaving some references lying around, I wonder if just reinstating something similar to the old hack wouldn't be easiest.
Related branches
- Vincent Ladeuil: Approve
- Andrew Bennetts: Pending requested
- Robert Collins: Pending requested
-
Diff: 521 lines (+230/-103) (has conflicts)5 files modifiedbzrlib/errors.py (+1/-0)
bzrlib/tests/TestUtil.py (+40/-1)
bzrlib/tests/__init__.py (+73/-102)
bzrlib/tests/test_selftest.py (+108/-0)
doc/en/release-notes/bzr-2.5.txt (+8/-0)
Changed in bzr: | |
milestone: | none → 2.5b3 |
status: | In Progress → Fix Released |
Unfortunately I don't think fixing this will help babune on windows (even though it helps me) as running the test suite in small pieces should mitigate this issue anyway.