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

I try to use Angular together with Glitch.com (something like stackblitz) but I cant use it with ng serve because it regulary exceeds the memory limit of 512 mb so its not usable.

Any idea what I can do? I want to use glitch.com to work on private projects from everywhere...

The app exceeded the memory limit. Stopping and pausing for 15 seconds.

I use latest Angular (9)

gotwig avatar Dec 31 '19 16:12 gotwig

This is really depressing, I am struggling from 2 days to deploy my app on aws t2 micro. I have memory swap of 4GB and still it;s giving the same error.

Rahut-5771 avatar Jan 05 '20 18:01 Rahut-5771

With Angular 9 the memory usage decreased significantly during ng serve, at least for me.

hryuk avatar Feb 09 '20 17:02 hryuk

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

Update: My Node.js is now using 2.6 GB of RAM when debugging Angular 8.2.6 😞

Update: My Node.js is now using 1..5 GB of RAM when debugging Angular 9.0.0 😮

blogcraft avatar Feb 12 '20 13:02 blogcraft

Since Angular 9, our project reached an all time high of 2.3 GB for ng serve and 0.7 GB for a process type-checker-worker. Webstorm using 2 GB on startup and the JS language service of Webstorm using 1.1 GB, we're already at over 6 GB RAM used just for basic client sided development tools. Add Chrome with Dev tools, Visual Studio, and SQL Server and fairly good developer machines with 16GB RAM are starting to tank a severe performance hit.

I can remember Angular's processes using way less RAM a year ago. I'm unsure what exactly caused this to progressiveley increase.

wartab avatar Feb 24 '20 16:02 wartab

Since Angular 9, our project reached an all time high of 2.3 GB for ng serve and 0.7 GB for a process type-checker-worker. Webstorm using 2 GB on startup and the JS language service of Webstorm using 1.1 GB, we're already at over 6 GB RAM used just for basic client sided development tools. Add Chrome with Dev tools, Visual Studio, and SQL Server and fairly good developer machines with 16GB RAM are starting to tank a severe performance hit.

I can remember Angular's processes using way less RAM a year ago. I'm unsure what exactly caused this to progressiveley increase.

Tried using only VS Code instead of WebStorm and Visual Studio?

blogcraft avatar Feb 24 '20 21:02 blogcraft

Is starting to get problematic in our company: Computers with not more than 8 GB RAM start to freeze. We're using Angular CLI 8.3.22. I hope Angular 9 makes it better.

According to @blogcraft it gets a little better, according to @wartab it's getting worse.

Is there more people having experience with 9?

joschne avatar Mar 11 '20 09:03 joschne

For me it is getting better (not good).Release build time earlyer was over 3 minutes with 3.5 memory of ram usage. Now under 2 minutes and 2gb with angular 9. I have a big project with devextreme coponents. I am using jetbrains rider, but also if I use the command console (windows) there is no difference. Thinking that rider uses 2.5 and Angular 2.5 for build, at this moment I would not recommend a machine under 12 gb. Sad but for me no other chance...

frankiDotNet avatar Mar 11 '20 09:03 frankiDotNet

Could a team member or a top colaborator from the Angular project give us some detailed information about why that happens? That RAM usage is horrible for some software houses.

arielmoraes avatar Apr 14 '20 06:04 arielmoraes

macbook pro 2015 core i7, 16gb ram, fans going crazy with ng build, ng test, ng server etc.
@angular/cli 8.3.21,

also most ci platforms have 4gb ram limit, so our tests and builds are failing on pipeline

Sarfarazsajjad avatar Apr 18 '20 18:04 Sarfarazsajjad

macbook pro 2015 core i7, 16gb ram, fans going crazy with ng build, ng test, ng server etc. @angular/cli 8.3.21,

also most ci platforms have 4gb ram limit, so our tests and builds are failing on pipeline

I use Azure DevOps for CI, maybe give it a shot?

blogcraft avatar Apr 19 '20 16:04 blogcraft

I think Angular core team has to come up with solution otherwise they are going to loosing developer.Because developer can not buy machine every year but they can learn new thing every year. image

vrkansagara avatar May 17 '20 13:05 vrkansagara

the CPU usage is insane as well. I've got ng serve running locally in the background and haven't touched the frontend for at least an hour, just left it idle. It's using 90% CPU and I'm not even using it.

This is on a MBP 15" Late 2019

intellix avatar May 17 '20 13:05 intellix

the CPU usage is insane as well. I've got ng serve running locally in the background and haven't touched the frontend for at least an hour, just left it idle. It's using 90% CPU and I'm not even using it.

This is on a MBP 15" Late 2019

High CPU usage (constant 90% on ng serve) on a MacBook Pro can be solved by installing newest version of fsevents The high memory usage is still a mystery though so any response from dev team would be great.

timothyTheCoder avatar May 22 '20 10:05 timothyTheCoder

Hi all,

This thread has been open for 3 years now and was originally reporting using Angular CLI 1.0.0-rc.2.

Since then, a lot of things changed in the entire eco-system, while memory usage might still be high when using ng serve and ng test today. It's very unlikely that the root cause is the same as that of 3 years ago.

Having all the feedback in a single thread makes it hard to get meaningful reports, or to inform people of what versions the regressions that affect them were fixed.

High memory usage can have a number of root causes ranging from a Node.js (EX version 11 is known to have memory related bugs), compiler, application architecture, NGCC or Angular CLI. Unfortunately without a reproduction (Even shared privately) it would be almost impossible to find and solve the root cause.

Thus, my recommendation would be to open new issue and provide all the information requested in the issue template, that way we will be able to action the issue.

Thank you all for your understanding.

alan-agius4 avatar May 26 '20 08:05 alan-agius4

Imagine closing the issue being the only response to this increasingly worsening problem.

wartab avatar May 26 '20 08:05 wartab

@wartab, on my machine a new Angular projects takes 366Mb for the main process + 169Mb for the forked checker during ng serve, of course as an application get bigger and bigger so does the memory requirements.

Screenshot 2020-05-26 at 12 05 10

Unfortunately, there is no silver bullet that solves all memory issues, and every problem here might very well have a different root cause. Yet there isn't enough information in a given comment to help use understand how we can reproduce the issue. So please help us to help you, by filling a new issue providing all the information required or even better a reproduction.

We definitely want to get to the bottom of this, but we cannot investigate and eventually fix something which we cannot reproduce.

alan-agius4 avatar May 26 '20 10:05 alan-agius4

@alan-agius4 in your perspective, is it normal a new project consuming almost 500 Mb of RAM? I think you've just reproduced the issue.

arielmoraes avatar May 26 '20 13:05 arielmoraes

@arielmoraes, there isn't much Angular CLI can do abut this. I would say that 500MB is resonable given the complexity of the Angular CLI.

Also, you can see that the TypeScript compiler can consume a GB on medium-sized projects, just search for high memory usage in the TypeScript issue queue.

If you are still not convinced, you can build the demo file from Building your first TypeScript file handbook, it consumes 152MB. So, I would say that 500MB for Angular CLI is very good. If you want to convince your self, here's a repo:

https://github.com/SchnWalter/typescript-memory-usage

That repo only provides this file:

function greeter(person) {
  return "Hello, " + person;
}

let user = "Jane User";

document.body.textContent = greeter(user);

If you run npm run build:log-memory-usage (linux/mac required for memory usage stats), you will see this output:

> [email protected] build:log-memory-usage /workspace/playground/typescript-memory-usage
> /usr/bin/time --verbose -- npm run build
> [email protected] build /workspace/playground/typescript-memory-usage
> tsc greeter.ts
Command being timed: "npm run build"
User time (seconds): 2.68
System time (seconds): 0.08
Percent of CPU this job got: 160%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.72
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 152856
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 39940
Voluntary context switches: 1976
Involuntary context switches: 343
Swaps: 0
File system inputs: 0
File system outputs: 16
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0

And you will see that the command has consumed 152MB for compiling the code above plus one comment. Yes code comments do count, so do blank lines, because they are represented in the TypeScript Abstract Syntax Tree as complex object instances.

SchnWalter avatar May 26 '20 14:05 SchnWalter

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.