Skip to content

[Bug]: Memory usage significantly increases in 30.0.0-beta.6 for certain tests #15660

@anomiex

Description

@anomiex

Version

30.0.0-beta.9

Steps to reproduce

Repeat the following using 30.0.0-beta.5 and 30.0.0-beta.6:

  1. Unzip this example repo: test.zip
  2. Install with your preferred package manager.
  3. Start monitoring system memory usage, then run jest.

Expected behavior

Memory usage is about the same between 30.0.0-beta.5 and 30.0.0-beta.6.

Actual behavior

With 30.0.0-beta.5, free memory decreases from 19G to 18G. Tests take about 5 seconds wall clock time.

With 30.0.0-beta.6, free memory decreases from 19G to 9.2G. Tests take about 7 seconds wall clock time.

Additional context

My system I used for testing has 32G memory and 16 CPU cores, which seems to mean Jest runs 10 child processes for the 10 test files included in the example repo.

The setTimeout in the tests is not necessary to reproduce, it's just there to make it easier to get memory measurements. It also continues to reproduce if the async is removed along with the awaited promise.

The require of the @wordpress/components package seems to be what's somehow bringing the memory usage way up. I don't know whether other large packages might do the same thing.

Attempting to measure memory usage within node (e.g. with node --inspect-brk) does not seem to reflect the increased memory usage. Or maybe I was just doing it wrong.

Using --runInBand shows a more modest effect: memory usage is still up in beta.6 compared to beta.5, but since it's doing one test at a time it doesn't go up as obviously as it does with 10 workers.

Environment

System:
    OS: Linux 6.12 Debian GNU/Linux 13 (trixie) 13 (trixie)
    CPU: (16) x64 AMD Ryzen 7 7840U w/ Radeon  780M Graphics
  Binaries:
    Node: 22.16.0 - /usr/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.9.2 - /usr/bin/npm
    pnpm: 10.11.1 - /usr/local/bin/pnpm
  npmPackages:
    jest: 30.0.0-beta.6 => 30.0.0-beta.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions