Webpack占用9GB内存是否正常?

根据Ubuntu node上的任务pipe理器有8个进程在运行900MB到1.3GB的内存。

那感觉太多了。 幸运的是我的电脑有12GB的内存,但是这太多了? 如果有的话,有什么想法,为什么这么多?

我的电脑每隔一段时间就会冻结一次,有时候当webpack检测到变化并开始运行时就会打嗝。

webpack:^ 3.6.0,捆绑追踪器:^ 0.2.0,仪表板:1.0.0-5,webpack-dev-server:^ 2.2.0,babel:^ 6.3.26

我正在使用WebpackDevServer:

 new WebpackDevServer(webpack(config), { headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'Content-Type, Authorization, x-id, Content-Length, X-Requested-With', 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS' }, historyApiFallback: true, hot: true, publicPath: config.output.publicPath, quiet: true, // Shows WebpackDashboard instead. watchOptions: { aggregateTimeout: 300, poll: 1000 } }).listen( ... ); 

这是我的webpack文件:

 const config = { context: __dirname, devtool: 'eval-cheap-module-source-map', module: { loaders: [ { test: /\.js[x]?$/, exclude: /node_modules/, loader: 'babel-loader' }, { test: /\.s[ac]ss$/, exclude: '/node_modules/', use: [{ loader: 'style-loader', options: { sourceMap: true } }, { loader: 'css-loader', options: { sourceMap: true } }, { loader: 'sass-loader', options: { sourceMap: true, includePaths: [path.resolve(__dirname)] } }] }, { test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/, exclude: '/node_modules/', loader: 'file-loader' }, { test: /\.(jpe?g|png|gif)$/, exclude: '/node_modules/', // If an image is less than 10kb, use data-url for images, otherwise // falls back to file-loader. loaders: ['url-loader?limit=10000&name=images/[hash:12].[ext]'] } ] }, resolve: { descriptionFiles: ['package.json'], extensions: ['.js', '.jsx', '.scss'], mainFiles: ['index'], modules: ['node_modules', path.resolve(__dirname)], } }; config.entry = { main: [ 'react-hot-loader/patch', 'babel-polyfill', './index.jsx', 'webpack/hot/only-dev-server', `webpack-dev-server/client?http://${ localConfig.ip }:${ localConfig.port }` ] }; config.output = { path: path.resolve('./dist/'), publicPath: `http://${ localConfig.ip }:${ localConfig.port }/assets/bundles/`, filename: '[name].js' }; config.plugins = [ new webpack.HotModuleReplacementPlugin(), new webpack.NoEmitOnErrorsPlugin(), // Used by Django. new BundleTracker({ filename: './webpack-stats-dev.json' }), new webpack.NamedModulesPlugin(), new DashboardPlugin(dashboard.setData) ]; 

如果有人知道一个好的问题列表,这将是非常有帮助的。

它看起来像你的进程需要1GB,但是因为它们被执行8次,作为单独的进程…然后他们需要8GB的内存。 这就是线程赢的地方。

如果testing出现问题,您可以强制GC。 在我的情况下,build设是相当快的。 获取依赖关系需要时间,testing执行也很昂贵。 如果这也是你的情况在这里寻找:

如果每100次请求手动调用gc(),则RSS不会超过70 MiB。

正如你所写,难题。 我认为你处于边缘。