STINNER Victor <victor.stin...@gmail.com> added the comment: I created PR 4489 to fix the memory leak for the "ignore "action". IMHO it's interesting to modify the "ignore" action because Python uses ignore many warnings by default:
haypo@selma$ python3 -c 'import pprint, warnings; pprint.pprint(warnings.filters)' [('ignore', None, <class 'DeprecationWarning'>, None, 0), ('ignore', None, <class 'PendingDeprecationWarning'>, None, 0), ('ignore', None, <class 'ImportWarning'>, None, 0), ('ignore', None, <class 'BytesWarning'>, None, 0), ('ignore', None, <class 'ResourceWarning'>, None, 0)] I created memory2.py (based on attached memory.py) to measure the leak. Currently, the "always" action doesn't leak, but "ignore" and "default" actions leak: haypo@selma$ ./python -W always memory2.py Memory peak grow: +3.2 kB Warning filters: [('always', re.compile('', re.IGNORECASE), <class 'Warning'>, re.compile(''), 0), ('ignore', None, <class 'BytesWarning'>, None, 0), ('always', None, <class 'ResourceWarning'>, None, 0)] haypo@selma$ ./python -W ignore memory2.py Memory peak grow: +26692.3 kB Warning filters: [('ignore', re.compile('', re.IGNORECASE), <class 'Warning'>, re.compile(''), 0), ('ignore', None, <class 'BytesWarning'>, None, 0), ('always', None, <class 'ResourceWarning'>, None, 0)] haypo@selma$ ./python -W default memory2.py Memory peak grow: +26693.2 kB Warning filters: [('default', re.compile('', re.IGNORECASE), <class 'Warning'>, re.compile(''), 0), ('ignore', None, <class 'BytesWarning'>, None, 0), ('always', None, <class 'ResourceWarning'>, None, 0)] With my PR 4489, the "ignore" action doesn't leak anymore: haypo@selma$ ./python -W ignore memory2.py Memory peak grow: +2.4 kB Warning filters: [('ignore', re.compile('', re.IGNORECASE), <class 'Warning'>, re.compile(''), 0), ('ignore', None, <class 'BytesWarning'>, None, 0), ('always', None, <class 'ResourceWarning'>, None, 0)] ---------- Added file: https://bugs.python.org/file47281/memory2.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue27535> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com