This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author multiks2200
Recipients multiks2200, rhettinger
Date 2021-04-23.12:24:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1619180640.61.0.560633050856.issue43911@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-04-23 12:24:00multiks2200setrecipients: + multiks2200, rhettinger
2021-04-23 12:24:00multiks2200setmessageid: <1619180640.61.0.560633050856.issue43911@roundup.psfhosted.org>
2021-04-23 12:24:00multiks2200linkissue43911 messages
2021-04-23 12:24:00multiks2200create