Skip to content

pluginData memory leak #3825

Closed
Closed
@TomokiMiyauci

Description

When pluginData was specified, memory usage increased with each rebuild.

main.mjs

import { context } from "esbuild";

const namespace = "testing";

const ctx = await context({
   stdin: {
    contents: `import "testing";`,
  },
  plugins: [
    {
      name: "testing",
      setup(build) {
        build.onResolve({ filter: /^testing$/ }, () => {
          return { path: "testing", namespace, pluginData: { value: "test" } };
        });

        build.onLoad({ filter: /.*/, namespace }, (args) => {
          return { contents: "console.log(0);" };
        });
      },
    },
  ],
  write: false,
  format: "esm",
  bundle: true,
});

setInterval(async () => {
  await ctx.rebuild();
}, 100);

If you run this, you will observe the Object usage increasing over time.

node --inspect main.mjs

The following images show a comparison of snapshots at two points in time:

memory-leak

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions