Describe the bug
Trying to create many objects leaks memory.
Platform information
- Python version 3.13.5
- How was python installed (python.org, anaconda, homebrew, ...) homebrew
- macOS version 15.5
- pyobjc version 11.1
To Reproduce
Run the following code:
import sys
import objc
import gc
NSData = objc.lookUpClass("NSData")
i = 0
while True:
i += 1
if i % 1000000 == 0:
print(i)
gc.collect()
with objc.autorelease_pool():
data = NSData.dataWithData_(b"This is a test")
del data
Expected behavior
Memory usage should stay relatively constant after the GC runs.
Additional context
I'm trying to figure out why my code (based on stdinreader.py and using AVSpeechSynthesizer) is leaking memory. According to the documentation, it doesn't look like I'm doing anything wrong, and this is an easily reproduceable test case.
I've also tried NSObject, which does the same thing.