Skip to content

nodejs: memory leak in Impit instance constructor #370

Closed

Description

@barjin

Each Impit instantiation takes up a constant amount of RSS, which is (seemingly) never freed.

import { Impit } from 'impit';

for (let i = 0; i < 30000; i++) {
  const impit = new Impit();

  if (i % 100 === 0) {
    console.log(process.memoryUsage().rss);
  }
}
Image

The expected behaviour should be constant memory usage, as the Impit instances from previous iterations are unreachable and should get GCed.

Activity

  1. self-assigned this
    on Jan 29, 2026
  2. added
    t-toolingIssues with this label are in the ownership of the tooling team.
    on Jan 29, 2026
  3. janbuchar commented on Jan 29, 2026

    @janbuchar

    Do you have any evidence of GC being run in your benchmark?

  4. barjin commented on Jan 29, 2026

    @barjin
    MemberAuthor

    Sorry for the incomplete graph, Node's GC only manages V8's internal heap - GC is happening there, see the following charts (jagged yellow line, better visible in the logarithmic view).

    Image Image

    Native Node addons will allocate their memory outside of V8's heap, but still in the process' resident set (all this is opaque from the OS's POV). That's why the RSS will grow in case of a memleak in a native addon.

  5. added a commit that references this issue on Jan 29, 2026
    3a769db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions