Jens <multiks2...@gmail.com> added the comment:
Thanks for your input. So i've run the tests with the List of Lists Queue class, there seems to be a resulting difference depending on what qsize() method I define, that is called my script. For an instance where qsize just return None, class QueueLists(list): def put(self, x): if not self or len(self[-1]) >= 66: self.append([]) self[-1].append(x) def get(self): if not self: raise IndexError block = self[0] x = block.pop(0) if not block: self.pop(0) return x # def qsize(self): # tot = 0 # for elem in self: # tot += len(elem) # return tot def qsize(self): return None The results are: >######### >del_after_puts False del_after_gets True n_puts 20000000 >before run >mem_pct 0.15% >------ put done ----- qsize None >mem_pct 38.06% >------ gets done ----- qsize None >mem_pct 2.35% >deleting queue after gets [] >mem_pct 2.35% >time elapsed 0:01:04.703969 For a Queue instance, where qsize() returns the actual size class QueueLists(list): def put(self, x): if not self or len(self[-1]) >= 66: self.append([]) self[-1].append(x) def get(self): if not self: raise IndexError block = self[0] x = block.pop(0) if not block: self.pop(0) return x def qsize(self): tot = 0 for elem in self: tot += len(elem) return tot the results are: >######### >del_after_puts False del_after_gets True n_puts 20000000 >before run >mem_pct 0.15% >------ put done ----- qsize 20000000 >mem_pct 38.05% >------ gets done ----- qsize 0 >mem_pct 2.35% >deleting queue after gets [] >mem_pct 0.18% >time elapsed 0:00:53.347746 So both instances leak as you've indicated, but the one that returns None as queue size does not get it's leak released after the instance is deleted which is a weird difference. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43911> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com