Interview Prep/Python for DevOps/Runtime, file, subprocess & encoding errors

`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.

All Python for DevOps questions Roadmap: Python for automation

More on Runtime, file, subprocess & encoding errors