Skip to content

Webpack memory usage on require #9781

@tiagonapoli

Description

@tiagonapoli

I don't know if this is a bug, but I noticed that just requiring webpack increases the memory usage by the process by around 1GB. Why is that? Could the increase number be optional (in size)?

This repo https://github.com/tiagonapoli/webpack-memory has the instructions to reproduce and has the following code:

const webpack = require('webpack')
setInterval(() => {
    console.log("Doing nothing :)")
}, 2000)

Memory usage:

Mem: 15617552K used, 701192K free, 478896K shrd, 1820824K buff, 6563680K cached
CPU:  13% usr  11% sys   0% nic  69% idle   0% io   0% irq   4% sirq
Load average: 1.27 1.26 1.05 4/1357 24
  PID  PPID USER     STAT   VSZ %VSZ CPU %CPU COMMAND
    1     0 root     S    1250m   7%   2   0% node index.js
   19     0 root     R     1524   0%   0   0% top

Memory usage commenting const webpack = require('webpack'):

Mem: 15008652K used, 1310092K free, 460732K shrd, 1823676K buff, 6574888K cached
CPU:  12% usr   7% sys   0% nic  80% idle   0% io   0% irq   0% sirq
Load average: 0.73 1.09 1.01 2/1288 17
  PID  PPID USER     STAT   VSZ %VSZ CPU %CPU COMMAND
    1     0 root     S     211m   1%   3   0% node index.js
   13     0 root     R     1524   0%   0   0% top

I'm concerned about this because I have a use case where there are around 15 pods in Kubernetes using webpack. Some worker processes are spawned, and when each of them require webpack they increase their memory usage by 1GB, resulting in a memory usage over time of something like this, which may be a problem:
Screenshot from 2019-10-08 12-18-03

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions