Memory usage of node process for ng test/serve is very high
Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ | | __ _ _ __ / | | | |
/ △ \ | ' \ / _ | | | | |/ _ | '| | | | | | |
/ ___ | | | | (| | || | | (| | | | || | | |
// __| ||_, |_,||_,|| _|||
|___/
@angular/cli: 1.0.0-rc.2
node: 6.10.1
os: win32 x64 (Win10)
@angular/common: 2.4.10
@angular/compiler: 2.4.10
@angular/core: 2.4.10
@angular/forms: 2.4.10
@angular/http: 2.4.10
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 2.4.10
@angular/platform-browser-dynamic: 2.4.10
@angular/router: 3.4.10
@angular/cli: 1.0.0-rc.2
@angular/compiler-cli: 2.4.10
Repro steps.
Run npm test or npm start which runs ng test / ng serve
The log given by the failure.
Memory usage for each node process is between 600MB and 1000MB. That's a lot, I think, although the application is really small (about 500 lines of code).
Desired functionality.
I can't believe that this high memory usage is intended.
Mention any other details that might be useful.
Do you need a dump file?
same issue here,
When running ng serve, I have two processes which will eat up 1.3 and 1.4GB, which makes 2.7GB for both ! this is ridiculously too large, it freezes my system eventually, since I also have a backend, a browser and an IDE to run.
system is ubuntu 18, command: node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng serve --host 0.0.0.0
@RodolpheGohard have you tried lowering max_old_space_size? 8192mb is 8gb... Try --max_old_space_size=1024 maybe? I was able to get it working on a system with 1gb of ram (t2.micro) that was previously crashing due to out of memory by setting --max_old_space_size=900 (900mb), it just made the build process slower.
@skylarmb it fails with a out of memory error
Crazy that this is still an issue in 2019...

This softens the situation: node --max_old_space_size=512 "./node_modules/@angular/cli/bin/ng" serve
Doesn't work - "JavaScript heap out of memory"
Crazy that this is still an issue in 2019...
Yes, can't even run it longer then 30 minus, before my computer runs stuck, due lack of memory. Pretty insane. Only happens with angular cli.
My Node.js is using 1.9 GB of RAM when debugging Angular 8.1.1 😞
My nodejs process is using 6+ GB of RAM when I run my tests. And also while developing nodejs process is using around 90% of my 6 cores processor. So sad... Will switch back to React than
Can't believe it hasn't been solved for over 2 years. I don't understand why ng serve needs ~600mb of RAM just to run the live development server. It does nothing and it "eats" so much RAM. And when you start changing files, it "eats" even more. Comparing to the create-react-app it's really hard to believe that it's absolutely necessary for Angular to reserve so much memory. Has anyone found a tip or something that could be responsible for such high usage?
@catchmareck my solution was quitting and getting a new job at a company that uses React instead of Angular (seriously) 😂 . A tiny Angular 6 app at my last company (a dozen or two components, like 4 routes, freshly bootstrapped) took like 3-4gb of ram to run the dev server or do a prod build. The massive enterprise React 16 app at my new job with 600+ components all in Typescript takes 800mb to run the dev server and about 1-1.5gb to do a production build.
Update: My Node.js is now using 2.6 GB of RAM when debugging Angular 8.2.6 😞
Most of our PC's only have 8 GB of RAM, so now we are facing the need to invest in new hardware just to be able to keep with angular's hunger. At this rate, how much is it going to grow...
I am also facing this issue. In Angular 6.X prod build of the project was taking only 2-3 minutes (I don't think it crossed 1GB of RAM usage) After upgrading to 7.x it takes 8-10 minutes in the same machine (RAM usage is ~5GB now) Like 3-4 times increase in build time after upgrading.
I am not sure if it is related to Node.js or CLI, but I am spending a solid amount of time building the project every day. :(
I have the same issue. I tested building the app without the build flag and took over 4GB of RAM and with the flag it took over 5GB of RAM. In the task manager the task that take more memory is node.js.
This image is before running the app:

This is after:

And this is the version I'm using:

Same here, I'm currently on Ubuntu 19.10, Angular CLI: 8.3.14, Node: 12.6.0.
Just after rebooting my PC, starting VScode and doing "ng s" I get this almost 700MB hungry basterd showing up ! with this bad boy and Chrome running at the same time, my PC just starts to beg for forgiveness and mercy...

Generating new App with ng new TestApp consuming around 300 mb when served with no changes
I can't believe this is still an issue after 2 years. My PC literally freezes when running 'ng serve'. Fedora 31 on Intel 8 core Xeon 8gb ram + SSD.
2019 anyone? I have windows 10 and the moment I run ng serve --open to run Angular app, the VS Code suddenly works slow, Visual Studio 2017 also becomes slow and the node.exe CPU usage is super high.
With Angular 9 right around the corner, let's see if this problem gets worse or better.
This softens the situation: node --max_old_space_size=512 "./node_modules/@angular/cli/bin/ng" serve Put in packeage.json in scripts....
A little bit better on my mac but using --max_old_space_size=1024
my app angular 8.3(few components) is run on ubuntu 16.4 with 2g memory and im facing the same issue. its being killed, and that's killing me...