PageRenderTime 13ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

Plain Text | 32 lines | 27 code | 5 blank | 0 comment | 0 complexity | 847f4596dca7e9fd210541294f8b4589 MD5 | raw file
 1This directory contains test cases that are known to leak references.
 2The idea is that you can import these modules while in the interpreter
 3and call the leak function repeatedly.  This will only be helpful if
 4the interpreter was built in debug mode.  If the total ref count
 5doesn't increase, the bug has been fixed and the file should be removed
 6from the repository.
 8Note:  be careful to check for cyclic garbage.  Sometimes it may be helpful
 9to define the leak function like:
11def leak():
12    def inner_leak():
13        # this is the function that leaks, but also creates cycles
14    inner_leak()
15    gc.collect() ; gc.collect() ; gc.collect()
17Here's an example interpreter session for test_gestalt which still leaks:
19>>> from test.leakers.test_gestalt import leak
20[24275 refs]
21>>> leak()
22[28936 refs]
23>>> leak()
24[28938 refs]
25>>> leak()
26[28940 refs]
29Once the leak is fixed, the test case should be moved into an appropriate
30test (even if it was originally from the test suite).  This ensures the
31regression doesn't happen again.  And if it does, it should be easier
32to track down.