`MemoryError` or the container gets `OOMKilled` while processing a big API export.
IntermediateTroubleshootingRuntime, file, subprocess & encoding errors
Answer
Likely causes → Loading the whole dataset into memory: resp.json() on a huge body, building giant lists, pandas.read_csv on multi-GB files, keeping all pages before processing.
Diagnose →
kubectl describe pod <pod> | grep -A3 "Last State" # Reason: OOMKilled
python -X tracemalloc=5 script.py # or memray run script.py
Fix → Stream: process page by page with generators, resp.iter_lines()/JSON Lines, pandas with chunksize, write results incrementally.
Prevent → Set memory limits and test with production-size data.
More on Runtime, file, subprocess & encoding errors
`KeyError: 'Tags'` while processing `describe_instances` output.Beginner`TypeError: can't compare offset-naive and offset-aware datetimes` in a snapshot-age check.Beginner`UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte` reading a log file.Intermediate`UnicodeEncodeError: 'ascii' codec can't encode character '✓'` when printing in a container.Intermediate`PermissionError: [Errno 13] Permission denied: '/var/log/app/report.json'`Intermediate`OSError: [Errno 24] Too many open files` in a long-running Python service.Intermediate