angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Memory usage of node process for ng test/serve is very high

Open kolbma opened this issue 9 years ago • 60 comments

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?

kolbma avatar Mar 24 '17 08:03 kolbma

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 avatar Jan 17 '19 17:01 RodolpheGohard

@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 avatar Jan 17 '19 19:01 skylarmb

@skylarmb it fails with a out of memory error

RodolpheGohard avatar Jan 18 '19 15:01 RodolpheGohard

Crazy that this is still an issue in 2019... screenshot from 2019-02-21 10-55-49

drewwiens avatar Feb 21 '19 17:02 drewwiens

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"

drewwiens avatar Feb 21 '19 17:02 drewwiens

Crazy that this is still an issue in 2019... screenshot from 2019-02-21 10-55-49

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.

tjvanderende avatar Apr 14 '19 09:04 tjvanderende

My Node.js is using 1.9 GB of RAM when debugging Angular 8.1.1 😞

blogcraft avatar Jul 19 '19 15:07 blogcraft

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

NuclleaR avatar Aug 23 '19 17:08 NuclleaR

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 avatar Sep 10 '19 14:09 catchmareck

@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.

skylarmb avatar Sep 11 '19 16:09 skylarmb

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...

blogcraft avatar Sep 12 '19 15:09 blogcraft

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. :(

achieverprince avatar Oct 09 '19 05:10 achieverprince

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: beforeNgServe

This is after: afterNgServe

And this is the version I'm using: ngVersion

jlzapata avatar Oct 23 '19 14:10 jlzapata

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...

ng_ram_hungry_basterd

WESquad-oldmember avatar Oct 30 '19 15:10 WESquad-oldmember

Generating new App with ng new TestApp consuming around 300 mb when served with no changes

ankurpowar avatar Nov 07 '19 10:11 ankurpowar

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.

simontol avatar Nov 08 '19 21:11 simontol

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.

dssagar93 avatar Nov 13 '19 07:11 dssagar93

With Angular 9 right around the corner, let's see if this problem gets worse or better.

blogcraft avatar Dec 05 '19 20:12 blogcraft

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

vpsnotas avatar Dec 18 '19 22:12 vpsnotas

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...

hamed6 avatar Dec 20 '19 07:12 hamed6