New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
valgrind reports leaks for test_zipimport #67957
Comments
Leaks happen only when both testDoctestFile and testDoctestSuite are run. I have extracted those two tests into
Note that when I remove support.modules_cleanup(*modules_before) from leak.py valgrind reports no leaks (in original test_zipimport those are run in setUp and tearDown). Output of |
Summary for ==18608== |
When calling gc.collect() after each test, I don't see any leak anymore. doTest() has a small leak: it prepends a path to sys.path, but it never removes it. Try attached leak2.py: it displays something like +254 kB. Uncomment the two following lines and the output will be close to +0 kB.
|
I tried leak2.py with valgrind, I've uncommented the lines you mentioned.
I've removed
Duh? Why does readline have this effect? |
zipimport has been rewritten in pure Python (bpo-25711). |
It's not strictly a memory leak: running the same code multiple time doesn't leak memory. It's just that Python allocates memory once and never releases it (doesn't releast it at exit). --- leak4.py: Updated and simplified script. If the code is run 10 times, it doesn't leak. With 1, 10 or 100 loops (LOOPS=100), Python still says the same at exit: $ ./python -I -X showrefcount leak4.py
[1574 refs, 664 blocks] Using cannot_deallocate2.patch of bpo-46417, I can see that multiple static types are not cleared at Python exit:
The _collections, itertools and _struct extensions implement types as static types which are not cleared at Python exit. It explains why Python says that there are still 664 memory blocks allocated at Python exit (664 blocks). I consider that this issue is a duplicate of bpo-40077. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: