GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Free threading memory leak · Issue #145615 · python/cpython Closed Labels 3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixestopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionThis bug was originally found by a colleague. Memory usage (RSS) keeps increasing even though allocated blocks stays essentially constant. Self contained reproducer below: import gc import sys import os import concurrent.futures def get_rss_mb(): with open("/proc/self/statm") as f: return int(f.read().split()[1]) * os.sysconf("SC_PAGE_SIZE") / (1024 * 1024) def work(_): return [bytearray(64) for _ in range(4000)] NUM_ITERATIONS = int(sys.argv[1]) if len(sys.argv) > 1 else 20 pool = concurrent.futures.ThreadPoolExecutor(max_workers=4) for i in range(NUM_ITERATIONS): futures = [pool.submit(work, j) for j in range(100)] results = [f.result() for f in futures] del futures, results # free worker-allocated objects on main thread gc.collect() gc.collect() blocks = sys.getallocatedblocks() print(f"iter {i:3d}: RSS={get_rss_mb():7.1f} MB {blocks=}") pool.shutdown() print(f"after shutdown: RSS={get_rss_mb():7.1f} MB") The problem is that we end up having orphaned mimalloc pages in the full queue, even though those pages have available blocks or are completely empty. They're "leaked" until the thread exits. NOTE: The bugs are limited out our mimalloc modifications. They're not in upstream mimalloc. I think there are at least two underlying bugs here:
Additionally, Linked PRsActivity
MetadataMetadataAssigneesLabels3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixestopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |