x
)- [x] bug report -> please search issues before submitting
- [ ] feature request
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
Run npm test or npm start which runs ng test / ng serve
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).
I can't believe that this high memory usage is intended.
Do you need a dump file?
This has been the case for a while, so in that sense it is intended (e.g. not a bug).
I do agree it's quite a bit and there's probably room for improvement there.
With a reasonably large project I get OOM when the process hits Node's memory limit. Since you can't set Node's memory limit via env var, I have to dig around manually to run the tests.
ฦ ng test
<--- Last few GCs --->
42309 ms: Mark-sweep 1364.9 (1435.8) -> 1364.7 (1435.8) MB, 1728.3 / 0.0 ms [allocation failure] [GC in old space requested].
43288 ms: Mark-sweep 1364.7 (1435.8) -> 1364.7 (1435.8) MB, 978.5 / 0.0 ms [allocation failure] [GC in old space requested].
44370 ms: Mark-sweep 1364.7 (1435.8) -> 1366.6 (1413.8) MB, 1081.1 / 0.0 ms [last resort gc].
45379 ms: Mark-sweep 1366.6 (1413.8) -> 1368.9 (1413.8) MB, 1009.0 / 0.0 ms [last resort gc].
@timruffles Yes, the memory usage of npm install is also crazy. But this is another topic.
Is the problem that developers don't understand that JSON-objects in memory need memory and isn't just a virtual, magic document from outer space ;-)
Running two concurrent ng serve
s, I had to increase the memory allocated for Docker from 2 GB to 4 GB just to prevent OOMing. This seems really wrong. Is it loading all of node_modules into RAM or something?
Agree. @angular/cli
makes my laptop's fans getting crazy.
I've made comparison of pure Webpack setup, create-react-app
and @angular/cli
and cli is much worse. Any ideas?
This issue is rather old but I've never had a problem on my local setup until recently updating to CLI v1.3.0
It's running on macOS Sierra 10.12.6 and I have to restart ng serve
twice a day because node runs out of memory.
The apps size is about 150 components, no big dependencies other than angular material.
Since there isnt a suitable recent ticket I can +1, im adding that we're having major issues with Jenkins and angular builds taking up way too much memory and causing the no response in 20000ms issue. From looking at the resources, excessive RAM usage from angular cli and npm seems to be the cause during builds
No solution for angular but I'm using now npm 5.4.2 and this version and some before (5.x.y) are much faster and use less memory.
I also have gotten to where I'm constantly restarting my ng serve
due to it running out of memory, and my app isn't very large at all, perhaps 30 components, plus Angular Material.
I'm on @angular/cli v 1.5.0
| node 6.12.0
| npm 5.4.2
, and ng serve
uses 1.1Gb of RAM... what the hell?!
Any update๏ผ Same issue using 'ng serve --hmr'
Same problem here !!!!
When you make changes it will swell !!! It starts low, every time it changes some file it increases.
Same issue. system freezes.
+1
This softens the situation: node --max_old_space_size=512 "./node_modules/@angular/cli/bin/ng" serve
Put in packeage.json in scripts....
Same here, working with latest version of all.. With about 15 components and 3 services getting 3 gb of ram consumption an browser is freezing..
+1, Same issue with me, every day need close and open Angular, my project based on Nebular ngx-Admin, about 30~40 components, any update on this issue?
Version details as below
Node: 8.11.3
OS: win32 x64
Angular: 6.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular-devkit/architect 0.8.3
@angular-devkit/build-angular 0.8.3
@angular-devkit/build-optimizer 0.8.3
@angular-devkit/build-webpack 0.8.3
@angular-devkit/core 0.8.3
@angular-devkit/schematics 0.8.3
@angular/cdk 5.2.5
@angular/cli 6.2.3
@ngtools/webpack 6.2.3
@schematics/angular 0.8.3
@schematics/update 0.8.3
rxjs 6.2.2
typescript 2.7.2
webpack 4.20.2
Memory running out was happening to me because I had a serializer file with a function returning an object with several entries.
function(obj) {
return {
key1: value1,
key2: value2,
...
key30: value30,
...
}
Also, some features in VS Code stopped working just by opening this file. After examining its Process Explorer, VS Code's tsserver
process was utilizing an enormous amount of memory (it was exploding when opening that file and not decreasing after closing it). So in my case the issue was probably related to TypeScript.
I fixed just using Object.assign()
instead of returning an object directly.
+1
I have a similar issue. I cant run typescript compilation after deploy on an EC2 instance with 1gb of ram (900+mb free), even with all optimizations turned off. It runs out of memory and crashes almost instantly.
"optimization": false,
"outputHashing": "all",
"sourceMap": false,
"extractCss": false,
"namedChunks": false,
"aot": false,
"extractLicenses": false,
"vendorChunk": false,
"buildOptimizer": false
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...
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)
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.
With Angular 9 the memory usage decreased significantly during ng serve
, at least for me.
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 ๐ฎ
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.
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?
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?
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...
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.
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
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?
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.
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
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.
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.
Imagine closing the issue being the only response to this increasingly worsening problem.
@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.
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 in your perspective, is it normal a new project consuming almost 500 Mb of RAM? I think you've just reproduced the issue.
@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:
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.
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._
Most helpful comment
@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.