[issue43050] threading timer memory leak
STINNER Victor
report at bugs.python.org
Fri Sep 24 11:51:58 EDT 2021
STINNER Victor <vstinner at python.org> added the comment:
I cannot reproduce the issue. IMO it has been fixed.
Moreover, you must join timers using timer.join(): a timer remains a thread.
Code:
---
import os
import threading
os.system(f"grep ^VmRSS /proc/{os.getpid()}/status")
# warmup
for n in range(10):
timer = threading.Timer(5, None)
timer.start()
timer.cancel()
timer.join()
os.system(f"grep ^VmRSS /proc/{os.getpid()}/status")
for n in range(1000):
timer = threading.Timer(5, None)
timer.start()
timer.cancel()
timer.join()
os.system(f"grep ^VmRSS /proc/{os.getpid()}/status")
---
Output on Linux with the main branch of Python (3.11):
---
VmRSS: 10924 kB
VmRSS: 11104 kB
VmRSS: 11104 kB
---
----------
nosy: +vstinner
resolution: duplicate -> fixed
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43050>
_______________________________________
More information about the Python-bugs-list
mailing list