Skip to content

[Bug] Memory leak in freshly generated Ember 3.28.8 app #20032

Closed

Description

@ctjhoa

🐞 Describe the Bug

With a newly generated app with only one newly generated component, Ember Container is leaked after test run.
If you keeps executing test runs your memory keeps getting bigger and bigger.

🔬 Minimal Reproduction

https://github.com/concordnow/ember-memory-leaks-test

😕 Actual Behavior

2022-03-18-095233_1920x1059_scrot
Heap memory keeps increasing and Ember Container is still retained in memory

🤔 Expected Behavior

From my understanding, Ember Container should be garbage collected and should not remain in heap memory after a test run.

🌍 Environment

  • Ember: - 3.28.8
  • Node.js/npm: - Node v17.3.1 / npm 8.5.0
  • OS: - Linux
  • Browser: - Chromium

➕ Additional Context

I've already discuss this issue on discord with @chriskrycho
https://discord.com/channels/480462759797063690/501388188762505216/954029886803169292

Activity

  1. chriskrycho commented on Mar 18, 2022

    @chriskrycho
    Contributor

    Thank you for reporting this! I've tagged it and hopefully someone will have a chance to poke at it sometime soon!

  2. pichfl commented on May 17, 2022

    @pichfl
    Contributor

    Difficult to say precisely, but we might be running into similar issues in our project.

  3. mountHouli commented on Jan 17, 2024

    @mountHouli

    Hi Ember folks!

    I'm using Hashicorp Vault. It uses Ember. My security team has flagged this issue and I am required to address it.

    Does this bug still exist in Ember? Does it exist in Ember 4.x.x? Does it exist in Ember 5.x.x?

    Thanks!

  4. johanrd commented on Feb 20, 2026

    @johanrd
    Contributor

    @ctjhoa I cannot reproduce the Container and doble Registry in your repro. Are you still able to?

    I cloned the reproduction repo and ran pnpm run test:ember --serve, taking heap snapshots after 1, 2, 10, and 20 reloads. The heap grows ~0.55 MB per reload and never stabilizes:

    Snapshot Heap self-size
    After 1st load 13.0 MB
    After 2nd load 13.6 MB
    After 10 reloads 18.7 MB
    After 20 reloads 23.8 MB

    However, the Ember Container and Registry are not the leaking objects (at least not in my reproduction). Registry stays at 1 instance and Container doesn't appear as retained.

    The actual leak is V8 compiled script contexts that are never garbage collected between test reloads. A programmatic diff of the heap snapshots shows:

    V8 internal Count at snap 1 Count at snap 20 Size leaked
    (script line ends) 13 132 9.4 MB
    Vendor bundle string (re-parsed copy) 2 28 419 KB
    BytecodeArray 2,351 3,363 165 KB
    ScopeInfo 2,513 3,934 124 KB
    (shared function info) 1,326 2,077 36 KB

    Each reload re-evaluates all <script> tags (vendor.js, test-support.js, testem.js, socket.io) but old V8 compilation contexts are never freed. The script URL entries themselves grow linearly
    (e.g., http://localhost:7357/assets/vendor.js goes from 1 → 22 instances, one per reload). QUnit/test-helper functions (pauseTest, resumeTest, setupContext, teardownContext) also accumulate ~1
    copy per reload.

    To me, this points to a test harness (testem) script reload issue rather than an Ember framework leak.

  5. kategengler commented on Jun 23, 2026

    @kategengler
    Member

    cc @NullVoxPopuli Do you think we should close this?

  6. NullVoxPopuli commented on Jun 23, 2026

    @NullVoxPopuli
    SponsorContributor

    aye

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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