rspack icon indicating copy to clipboard operation
rspack copied to clipboard

Memory leak when using `@rspack/core` API

Open Nikaple opened this issue 1 year ago • 8 comments

System Info

  System:
    OS: Linux
    CPU: (16) x64 Intel(R) Xeon(R) Platinum 8255C CPU @ 2.50GHz
    Memory: 19.11 GB / 31.10 GB
    Container: Yes
    Shell: 5.0.2 - /bin/zsh
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
  npmPackages:
    @rspack/cli: latest => 0.1.10 
    @rspack/core: ^0.1.10 => 0.1.10 

Details

screenshot

With webpack

screenshot-webpack

Reproduce link

No response

Reproduce Steps

  1. Create a project npm create rspack@latest
  2. Create a script to compile consecutively with @rspack/core
  3. Run the script to get memory leak

Script content:

const { rspack } = require('@rspack/core')
const config = require('./rspack.config')

function compile() {
    const compiler = rspack(config);
    return new Promise((resolve, reject) => {
        compiler.run((err, stat) => {
            if (err) {
                return reject(err)
            }
            return resolve(stat)
        })
    })
}


async function main() {
    await compile();

    setTimeout(() => {
        const memory = process.memoryUsage();
        console.log(`Total memory used: ${Math.round(memory.rss / 1024 / 1024)} MB`)
        main()
    }, 1000);
}

main().catch(console.error)

Nikaple avatar May 16 '23 08:05 Nikaple

Confirmed. How did you discover this? We don't normally import it as a package 🤔

Boshen avatar May 16 '23 09:05 Boshen

I am currently in the process of migrating a complex build tool that is based on webpack. The tool has the ability to compile multiple projects simultaneously, utilizing webpack's core API. However, when attempting to migrate it to rspack, I encountered a persistent issue of the process being killed due to an OOM error.

Nikaple avatar May 16 '23 12:05 Nikaple

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] avatar Jul 17 '23 07:07 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] avatar Dec 15 '23 15:12 stale[bot]

bump!

pratyushseq avatar Jan 16 '24 04:01 pratyushseq

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] avatar Apr 05 '24 08:04 stale[bot]

bump

Nikaple avatar Apr 25 '24 06:04 Nikaple

@Nikaple I believe this issue has been mitigated: image But there's still some leaking problem with the Compiler and Compilation. It's under our investigation.

h-a-n-a avatar Apr 25 '24 11:04 h-a-n-a

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] avatar Jun 24 '24 12:06 stale[bot]

bump

h-a-n-a avatar Jun 25 '24 11:06 h-a-n-a

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] avatar Aug 24 '24 11:08 stale[bot]

Image

The image says rsbuild, but it seems to be related to rspack itself

This happens with the following config

import { defineConfig } from "@rsbuild/core";
import { pluginSvgr } from "@rsbuild/plugin-svgr";
import { pluginBabel } from "@rsbuild/plugin-babel";
import { pluginReact } from "@rsbuild/plugin-react";

export default defineConfig({
  plugins: [
    pluginReact(),
    pluginBabel({
      include: /\.(?:jsx|tsx)$/,
      babelLoaderOptions(opts) {
        opts.plugins?.unshift("babel-plugin-react-compiler");
      },
    }),
    pluginSvgr(),
  ],
  html: {
    template: "./index.html",
  },
  source: {
    entry: {
      index: "./src/index.tsx",
    },
    alias: {
      "@": "./src",
      "@lib": "./src/app/resources",
      "@/*": "./src/*",
    },
  },
  output: {
    distPath: {
      root: "build",
    },
    minify: {
      css: true,
      js: true,
    },
  },
  dev: {
    progressBar: true,
    hmr: true,
    watchFiles: {
      paths: ["./index.html", "./src/**/*"],
    },
  },
  server: {
    port: 3000,
    strictPort: true,
  },
});

ahqsoftwares avatar Oct 22 '24 17:10 ahqsoftwares