Nx: memoryLimit / maxWorkers for nx serve

Created on 14 Apr 2020  路  9Comments  路  Source: nrwl/nx

  • [x] I am running the latest version
  • [x] I checked the documentation (nx.dev) and found no answer
  • [x] I checked to make sure that this issue has not already been filed
  • [x] I'm reporting the issue to the correct repository (not related to React, Angular or any dependency)

Expected Behavior

memoryLimit and maxWorkers options are available for nx serve

Current Behavior

Using --memoryLimit flag causes an error like this:

Schema validation failed with the following errors:
  Data path "" should NOT have additional properties(maxWorkers).

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Run nx serve --maxWorkers=1

Context

Please provide any relevant information about your setup:

@nrwl/angular : Not Found
@nrwl/cli : 9.2.2
@nrwl/cypress : Not Found
@nrwl/eslint-plugin-nx : 9.1.2
@nrwl/express : Not Found
@nrwl/jest : 9.2.2
@nrwl/linter : 9.2.1
@nrwl/nest : 9.2.2
@nrwl/next : Not Found
@nrwl/node : 9.2.1
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 9.2.2
@nrwl/web : Not Found
@nrwl/workspace : 9.2.2
typescript : 3.8.3

Ref #2716: It would be great to have those flags not only work for building but also serving an application. My development machine only has so much RAM available and I'm constantly hitting 95-99% RAM usage while developing inside WSL 2. Plus, I really don't need 6 workers@2GB, it's too much.

Maybe it's a usage problem and this is possible, if so, where can I find this in the documentation?

core enhancement

Most helpful comment

is there any update?
My laptop is 16gb but it is DIEing very badly

All 9 comments

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nrwl community! 馃檹

Reply to keep this active

Can we add this to angular and nestjs. Nx is obliterating my RAM when tyring to run my nestjs.

is there any update?
My laptop is 16gb but it is DIEing very badly

@yeomann Had the same issue. I was able to prevent my project from creating 14+ workers by using this option in my angular.json

my-project.architect.build.options {... other options, "maxWorkers": 1 }

It helps with the workers my memory consumption is still high and even more when you use VS, Chrome, and Nx :(

thanks man @alexesca
i am using nx with Nest project, added in workspace.json for the main "architect.build.options" and it worked.
nice trick

edit:
i added memoryLimit as well, seems to be working
image
image

Hey @yeomann,
Does this rule apply too when building the project?

i have not tested @ericgoe

@ericgoe It is defined in the build. I had this issue when running nx serve, but then I realized that nx serve has to build the project before serving it. The "maxWorkers" and "memoryLimit" in the build option help with any other commands that use build in the pipeline process.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joelmuskwe picture joelmuskwe  路  3Comments

SWGeekPD picture SWGeekPD  路  3Comments

dereklin picture dereklin  路  3Comments

zpydee picture zpydee  路  3Comments

jon301 picture jon301  路  3Comments