pytest-dev / pytest-dev/pytest

Memory usage increases rapidly as the number of tests grows

Open
#10,605 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

status: help wanted type: performance
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

Hi !

I am witnessing this memory usage increase on fpdf2, using memunit: https://github.com/PyFPDF/fpdf2/issues/641
A contributor also mentioned that it was reported on StackOverflow some years ago:
https://stackoverflow.com/questions/20900380/py-test-excessive-memory-usage-with-large-number-of-tests

In short: for a tests suite with ~1000 unit tests, I have witnessed an increase in memory usage of more than 10MB for 40 unit tests added.

Is this surprising to you, or expected?

And secondly, could there be optimizations to make, in pytest or in my tests suite, in order to lower this memory usage?

I have searched the issues & discussions history about this but found nothing anwering those questions:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported memory growth with memunit and a suite of about 1,000 unit tests, then review the linked fpdf2 issue and Stack Overflow report for comparison. Done means determining whether the growth is expected and identifying any pytest or test-suite optimizations that lower it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.