Python Package

Memory Profiling

Measuring and reducing the memory footprint of mgpy runs (without analyzing application runtime leaks).

Early Access: Until 2026-12-31

In mgpy, memory usage often creeps up slowly: large reports, history files, caches or build artifacts grow longer unnoticed than simple runtime spikes.

Key points

  • CLI: On Windows the examples use the recommended py -3.12 -m <module> ... form (for example py -3.12 -m manifestguard ...). On Linux/macOS this usually maps to python3.12 -m ....
  • Watch mgpy runs that produce large JSON reports, long history files and repeatedly loaded dependencies.
  • Short-lived CLI runs should not leave unnecessary global caches behind.
  • Memory profiling matters most when extended checks run in CI or on smaller runners.

Recommended mgpy workflow

  1. Build reproducible scenarios with larger projects or large report files first.
  2. Then identify objects and files that keep growing across multiple mgpy runs without reason.
  3. After memory fixes, write the same reports again and confirm the output still matches semantically.

Quick start

py -3.12 -m manifestguard check --extended --report .manifestguard/large-run.json
py -3.12 -m manifestguard baseline --list
py -3.12 -m manifestguard export-metrics --output metrics.json