"""Holds about 20 MB on the main thread and 5 MB from a worker thread, then ends.""" import sys import threading import time KEPT = [] def blocks(count): return [bytearray(1024) for _ in range(count)] def worker(): KEPT.append(blocks(5_000)) def main(): KEPT.append(blocks(20_000)) thread = threading.Thread(target=worker) thread.start() thread.join() print("done", flush=True) if "--wait" in sys.argv: while True: time.sleep(0.05) if __name__ == "__main__": main()