You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Excessive QSBR memory usage when delay freeing large blocks. #132519
I ran across this while profiling memory usage in #130771. The results are same for both that and list objects which use QSBR to free memory, so this is a QSBR thing. Note this is an extreme synthetic case, this CAN happen but does not mean it WILL happen in real-world apps.
Memory usage numbers:
VmHWM
GIL 135104 kB - normal GIL-enabled baseline
noGIL 6702788 kB - free-threaded current QSBR behavior
Test script:
importthreadingfromqueueimportQueuedefthrdfunc(queue):
whileTrue:
l=queue.get()
l.append(0) # force resize in non-parent thread which will free using _PyMem_FreeDelayed()queue=Queue(maxsize=2)
threading.Thread(target=thrdfunc, args=(queue,)).start()
whileTrue:
l= [None] *int(3840*2160*3/8) # sys.getsizeof(l) ~= 3840*2160*3 bytesqueue.put(l)
Activity
pythongh-132519: fix excessive mem usage in QSBR with large blocks
ZeroIntensity commentedon Apr 19, 2025
Triage: should we close this?
kumaraditya303 commentedon Jun 10, 2025
Closing this in favor of #133136