[issue43050] threading timer memory leak

2021-09-24 Thread STINNER Victor


STINNER Victor  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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43050] threading timer memory leak

2021-01-27 Thread fengjiang


fengjiang  added the comment:

yes, I find similar issues,the use the 
patch(https://github.com/python/cpython/pull/15228/files) to fix the bug

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43050] threading timer memory leak

2021-01-27 Thread Martin Panter


Martin Panter  added the comment:

Perhaps this is caused by Issue 37788. Python 3.7.4 introduced a leak for any 
thread that doesn't get its "join" method called. Timer is a subclass of 
Thread, so to confirm, see if calling "timer.join()" after "cancel" will make 
the leak go away.

--
nosy: +martin.panter
resolution:  -> duplicate
superseder:  -> fix for bpo-36402 (threading._shutdown() race condition) causes 
reference leak
type: performance -> resource usage

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43050] threading timer memory leak

2021-01-27 Thread fengjiang


New submission from fengjiang :

Hi,we are transfering code from python2.7 to 3.7 and find that using 
threading.timer will cause memory leak. It works fine in python2.7 but not 3.7. 
To repreduce the problem, you can simply run the code below.

While True:
timer = threading.Timer(5, None)
timer.start()
timer.cancel()

you will find the memory of progress increases rapidly

--
components: Library (Lib)
messages: 385831
nosy: fengjiang
priority: normal
severity: normal
status: open
title: threading timer memory leak
type: performance
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com