Describe the bug
Running zyra visualize-timeseries on even a tiny CSV inside a Kubernetes pod causes the container to terminate with exit code 137. kubectl describe pod shows OOMKilled.
Steps to reproduce
- Deploy Zyra in Kubernetes with ~8 GiB memory limit.
- Run:
zyra visualize-timeseries \
--input downloads/airtravel.csv \
--x Month \
--y 1958 \
--output outputs/airtravel.png
- Pod crashes with
OOMKilled.
Expected behavior
Plot should render successfully with modest memory usage.
Root cause analysis
src/zyra/visualization/timeseries_manager.py imports matplotlib.pyplot without forcing a non-interactive backend.
- In headless pods, Matplotlib defaults to interactive backends (
TkAgg, Qt5Agg), which misbehave and leak memory.
- Figures are not always closed (
plt.close(fig) missing), leading to accumulation.
Proposed fix
- Add:
import matplotlib
matplotlib.use("Agg")
before importing pyplot.
- Ensure
plt.close(fig) after save to free memory.
Environment
- Zyra
main branch
- Kubernetes pod with memory limit 8 GiB
- MPLBACKEND unset