coveragepy-json-memory-repro.zip
Describe the bug
Coverage.py 7.15.1 introduces a large memory-usage regression when generating a JSON report from a sizeable branch-coverage database.
Using the attached synthetic reproducer with the same source tree, configuration, and .coverage database:
| Version |
Runtime |
Maximum RSS |
| 7.15.0 |
30.00s |
197 MiB |
| 7.15.1 |
25.79s |
1,182 MiB |
This is approximately a 6x increase in peak RSS between 7.15.0 and 7.15.1.
This was originally causing a CI runner on our project to hang due to it being OOM (we observed a 5x increase there.
The excessive memory usage occurs during the coverage json command.
To Reproduce
-
What version of Python are you using?
CPython 3.10.17.
-
What version of coverage.py shows the problem?
Coverage.py 7.15.1 shows the regression. Coverage.py 7.15.0 does not.
Relevant output from coverage debug sys:
coverage_version: 7.15.1
core: -none-
CTracer: available
configs_read: pyproject.toml
python: 3.10.17
platform: macOS-26.5.1-arm64-arm-64bit
implementation: CPython
-
What versions of what packages do you have installed?
The reproducer only requires Coverage.py and its TOML extra:
coverage==7.15.1
tomli==2.0.1
-
What code shows the problem?
The attached coveragepy-json-memory-repro.zip is a self-contained, synthetic reproducer. It generates:
4,114 synthetic Python modules
744,634 recorded arcs
a 26 MiB coverage database
a 27 MiB JSON report
It contains no application or third-party source code.
-
What commands should we run to reproduce the problem?
mkdir coveragepy-json-memory-repro
unzip coveragepy-json-memory-repro.zip -d coveragepy-json-memory-repro
cd coveragepy-json-memory-repro
python3.10 -m venv .venv
source .venv/bin/activate
python -m pip install 'coverage[toml]==7.15.0'
python make_reproducer.py
COVERAGE_FILE=.coverage \
/usr/bin/time -l python -m coverage json -o coverage-7.15.0.json
python -m pip install --force-reinstall 'coverage[toml]==7.15.1'
COVERAGE_FILE=.coverage \
/usr/bin/time -l python -m coverage json -o coverage-7.15.1.json
On Linux, use /usr/bin/time -v instead of /usr/bin/time -l.
The observed maximum resident set sizes on macOS ARM64 were:
coverage 7.15.0: 206,995,456 bytes
coverage 7.15.1: 1,239,580,672 bytes
Expected behavior
coverage json in 7.15.1 should use memory comparable to 7.15.0 for the same source tree and coverage database. The 6x increase can cause the command to fail on memory-constrained CI runners where 7.15.0 completes successfully.
Additional context
coveragepy-json-memory-repro.zip
Describe the bug
Coverage.py 7.15.1 introduces a large memory-usage regression when generating a JSON report from a sizeable branch-coverage database.
Using the attached synthetic reproducer with the same source tree, configuration, and
.coveragedatabase:This is approximately a 6x increase in peak RSS between 7.15.0 and 7.15.1.
This was originally causing a CI runner on our project to hang due to it being OOM (we observed a 5x increase there.
The excessive memory usage occurs during the
coverage jsoncommand.To Reproduce
What version of Python are you using?
CPython 3.10.17.
What version of coverage.py shows the problem?
Coverage.py 7.15.1 shows the regression. Coverage.py 7.15.0 does not.
Relevant output from
coverage debug sys:What versions of what packages do you have installed?
The reproducer only requires Coverage.py and its TOML extra:
What code shows the problem?
The attached
coveragepy-json-memory-repro.zipis a self-contained, synthetic reproducer. It generates:It contains no application or third-party source code.
What commands should we run to reproduce the problem?
On Linux, use
/usr/bin/time -vinstead of/usr/bin/time -l.The observed maximum resident set sizes on macOS ARM64 were:
Expected behavior
coverage jsonin 7.15.1 should use memory comparable to 7.15.0 for the same source tree and coverage database. The 6x increase can cause the command to fail on memory-constrained CI runners where 7.15.0 completes successfully.Additional context