Skip to content

visualize-timeseries crashes with OOM (exit code 137) in headless/Kubernetes environments #167

@Hackshaven

Description

@Hackshaven

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

  1. Deploy Zyra in Kubernetes with ~8 GiB memory limit.
  2. Run:
    zyra visualize-timeseries \
      --input downloads/airtravel.csv \
      --x Month \
      --y 1958 \
      --output outputs/airtravel.png
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions