/Lib/test/leakers/README.txt

http://unladen-swallow.googlecode.com/ · Plain Text · 32 lines · 27 code · 5 blank · 0 comment · 0 complexity · 847f4596dca7e9fd210541294f8b4589 MD5 · raw file

  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. Note: be careful to check for cyclic garbage. Sometimes it may be helpful
  8. to define the leak function like:
  9. def leak():
  10. def inner_leak():
  11. # this is the function that leaks, but also creates cycles
  12. inner_leak()
  13. gc.collect() ; gc.collect() ; gc.collect()
  14. Here's an example interpreter session for test_gestalt which still leaks:
  15. >>> from test.leakers.test_gestalt import leak
  16. [24275 refs]
  17. >>> leak()
  18. [28936 refs]
  19. >>> leak()
  20. [28938 refs]
  21. >>> leak()
  22. [28940 refs]
  23. >>>
  24. Once the leak is fixed, the test case should be moved into an appropriate
  25. test (even if it was originally from the test suite). This ensures the
  26. regression doesn't happen again. And if it does, it should be easier
  27. to track down.