Message369443
Hi everyone,
I have found a memory leak when using Queue and Condition from threading library.
The issue can be reproduced with the following code:
========================================================
import queue
import threading
class MemoryTest(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.queue = queue.Queue()
self.cv = threading.Condition()
def put(self, msg):
self.queue.put(msg)
with self.cv:
self.cv.notify()
def run(self):
while True:
while not self.queue.empty():
self.queue.get()
self.queue.task_done()
with self.cv:
self.cv.wait_for(lambda: not self.queue.empty())
================================================================
If you run a MemoryTest object in another thread, by calling its start() method, and you send it messages by using its put() method, you will see how RAM memory usage starts increasing.
This behaviour has been observed in Windows (64 bits) with Python 3.6, 3.7 & 3.8, but not with Python 3.5.
Thank you so much. |
|
Date |
User |
Action |
Args |
2020-05-20 11:35:48 | Cristian Martinez de Morentin | set | recipients:
+ Cristian Martinez de Morentin, paul.moore, tim.golden, zach.ware, steve.dower |
2020-05-20 11:35:48 | Cristian Martinez de Morentin | set | messageid: <1589974548.09.0.894000250375.issue40699@roundup.psfhosted.org> |
2020-05-20 11:35:47 | Cristian Martinez de Morentin | link | issue40699 messages |
2020-05-20 11:35:47 | Cristian Martinez de Morentin | create | |
|