Home | History | Annotate | only in /external/python/cpython2/Lib/test/leakers
Up to higher level directory
NameDateSize
__init__.py06-Dec-20170
README.txt06-Dec-20171.1K
test_ctypes.py06-Dec-2017329
test_dictself.py06-Dec-2017232
test_gestalt.py06-Dec-2017275
test_selftype.py06-Dec-2017293

README.txt

      1 This directory contains test cases that are known to leak references.
      2 The idea is that you can import these modules while in the interpreter
      3 and call the leak function repeatedly.  This will only be helpful if
      4 the interpreter was built in debug mode.  If the total ref count
      5 doesn't increase, the bug has been fixed and the file should be removed
      6 from the repository.
      7 
      8 Note:  be careful to check for cyclic garbage.  Sometimes it may be helpful
      9 to define the leak function like:
     10 
     11 def 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()
     16 
     17 Here's an example interpreter session for test_gestalt which still leaks:
     18 
     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]
     27 >>> 
     28 
     29 Once the leak is fixed, the test case should be moved into an appropriate
     30 test (even if it was originally from the test suite).  This ensures the
     31 regression doesn't happen again.  And if it does, it should be easier
     32 to track down.
     33