Closed ghost closed 5 years ago
Also got this error.
Locking @ngtools/webpack to version 1.5.4 helps.
I had to increase memory given to Node, as well as bump TS to 2.4.2, but after that I did get a successful build. looking forward to NG5 AoT compiler
Same problem here after updating to @angular/cli 1.3.0.
@williangd also for me with 1.3.0
I've also been getting the out of memory issue when running ng serve
. It works fine for hours, but if I've been developing for a while (I've seen it anywhere from 2-5 hours) I will get the out of memory crash. When rerunning the serve command, I can go typically for another 2-5 hours. The first time I saw this was when updating to a beta version of 1.3, but I haven't seen an improvement with the current release.
For me it also happens with the normal "ng serve" after upgrading to 1.3 version, every time the project recompiles, its takes more time than the previous (6s, 10s, 30s, 60s) and after 4 or 5 times, it goes out of memory.
Same issue.
95% emitting <--- Last few GCs --->
160332 ms: Mark-sweep 1346.8 (1439.3) -> 1346.7 (1439.3) MB, 648.6 / 0.0 ms [allocation failure] [scavenge might not succeed]. 160934 ms: Mark-sweep 1346.7 (1439.3) -> 1346.8 (1439.3) MB, 602.0 / 0.0 ms [allocation failure] [scavenge might not succeed]. 161564 ms: Mark-sweep 1346.8 (1439.3) -> 1346.8 (1423.3) MB, 629.5 / 0.0 ms [last resort gc]. 162181 ms: Mark-sweep 1346.8 (1423.3) -> 1346.7 (1423.3) MB, 616.9 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0000009DB903FA99
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
tsc -v Version 2.4.2
@angular/cli: 1.3.0 node: 6.11.2 os: win32 x64
How is upgrading to typescript 2.4.2 working. You will get build issues from RxJs as they 2.4 broke the typings of rxjs
This problem is happening as well for our project. Can't build aot on build server with the same javascript heap out of memory. We are also using the experimental webpack 3 support.
@sbabeal just go to RxJS 5.4.2
For us - building locally with
ng build --target=production --environment=prod --base-href /myproject/ --aot --build-optimizer
works just fine, but when we build it on our server, we get the
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
error. However, if we remove the --build-optimizer everything runs fine.
I've tried adding the increase-memory-limit
library, but without any luck.
Is there a fix to this that actually works?
Kind regards Chris
Tried latest version of typescript and still didn't help. Locally it builds but consumes 1.5 gigs of memory. Seems quite excessive.
92% chunk asset optimization <--- Last few GCs --->
[3933:0x2a7d710] 355436 ms: Mark-sweep 1395.8 (1546.4) -> 1395.3 (1546.4) MB, 975.3 / 0.0 ms allocation failure GC in old space requested [3933:0x2a7d710] 356584 ms: Mark-sweep 1395.3 (1546.4) -> 1395.3 (1546.9) MB, 976.0 / 0.0 ms allocation failure GC in old space requested [3933:0x2a7d710] 357953 ms: Mark-sweep 1395.3 (1546.9) -> 1395.3 (1539.9) MB, 1195.7 / 0.0 ms last resort [3933:0x2a7d710] 359143 ms: Mark-sweep 1395.3 (1539.9) -> 1395.3 (1539.9) MB, 1188.8 / 0.0 ms last resort
<--- JS stacktrace --->
==== JS stack trace =========================================
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [@angular/cli]
2: 0x12b717c [@angular/cli]
3: v8::Utils::ReportOOMFailure(char const, bool) [@angular/cli]
4: v8::internal::V8::FatalProcessOutOfMemory(char const, bool) [@angular/cli]
5: v8::internal::Factory::NewCode(v8::internal::CodeDesc const&, unsigned int, v8::internal::Handle
We seem to face the error even on allocating 12GB of memory for the build. Is there any way to debug what is causing the memory leak? also, could this be solved by implementing lazy loading of modules, since this is during build time?
Commands used: 1.node --max_old_space_size=12000 ./node_modules/@angular/cli/bin/ng build --prod --aot --env=prod
The build is working only with --sourcemap=false and --aot=false; but this is causing memory leaks and page load issues in the browser due to huge application size.
StackTrace:-
[INFO]
[INFO] <--- Last few GCs --->
[INFO]
[INFO] [11944:0x2710b70] 898052 ms: Mark-sweep 11998.2 (13529.5) -> 11998.2 (13529.5) MB, 4991.9 / 0.0 ms allocation failure GC in old space requested
[INFO] [11944:0x2710b70] 903445 ms: Mark-sweep 11998.2 (13529.5) -> 11998.1 (13434.0) MB, 5366.9 / 0.0 ms last resort
[INFO] [11944:0x2710b70] 908749 ms: Mark-sweep 11998.1 (13434.0) -> 11998.1 (13378.0) MB, 5266.9 / 0.0 ms last resort
[INFO]
[INFO]
[INFO] <--- JS stacktrace --->
[INFO]
[INFO] ==== JS stack trace =========================================
[INFO]
[INFO] Security context: 0x2b8a8b3a66a1
[INFO]
I don't know if it can help someone but we had the same problem after upgrading to version 1.3.0. And we had others problem too : slow compilation and bad names for generated chunk.
All our problems were solved with this : https://github.com/angular/angular-cli/pull/7338
FTR, for one project, we abandoned Angular because of this. No amount of --max_old_space_size helps anymore.
Great work alienating enterprise users.
There's always an option to eject the app.
What do you mean by ejecting the application?
On Tue, Aug 22, 2017 at 5:12 PM, Arseny E. Naryshkin < notifications@github.com> wrote:
There's always an option to eject the app.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/5618#issuecomment-324021572, or mute the thread https://github.com/notifications/unsubscribe-auth/ADuwsXkLSkoHTg9-AMuUESUfM2sCLVbOks5satPRgaJpZM4Mn-Nn .
Still a problem for us even after CLI upgrade to 1.3.1 and @angular upgrade to 4.3.5
tried typescript 2.5 but run into some compilation problems. we're on 2.4.2.
edited:
On our local machines or our gitlab runner instances we can't reproduce the problem. For some reason the build only fails on our jenkins box. The only difference I've been able to gather is jenkins is on a slightly older version of node/npm version:
v6.9.1
3.10.8
instead of
v6.11.0
3.10.10
fixed by changing our production npm build script to:
"build-prod": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --prod --aot",
Not so much a fix as it is a brute force work-around, but it'll at least buy time while we figure out what's eating up all the heap space.
@Masquer how would eject help? It's actually a webpack problem.
@notsonotso oh, it will not then.
my app, however, fails to compile by ng with 'heap out of memory' error, but does as ejected.
Here's a related, solved issue in angular-seed. I hope it helps someone.
No amount of setting max-old-space-size
helped on our project. However, as we only build AOT in prod, we have temporarily disabled sourcemaps which seemed to fix it for us on our CI server.
Like @mattem I have not been able to get the max-old-space-size to work either. I do not if I am fully setting it up right though since the build process I have uses webpack with "ngtools/webpack".
Same issue, but we've found a more reliable workaround to increase the memory limit.
Since Node 8.x, you can set a NODE_OPTIONS
environment variable, and pass in the --old-max-space-size
flag. We currently need 6GB.
E.g. on Windows CMD: set NODE_OPTIONS=--old-max-space-size=6411
before running the AOT build.
I wonder if there is a child process that doesn't get the arguments that are set on the node executable.
I know, and trust me, I'm just as much struggling with this. Not fun when the build server starts to run out of memory. It's a serious problem that should be addressed. This workaround just helped me to limp along a little farther, just like turning off the source maps. Your mileage may vary.
Hello. this problem is serious.
On my computer I was limiting to 8Gb and the ng build was working fine. (with old-max-space-size)
But now I've got a big big project and believe me, out of memory.
I have a code generator that builds everything perfectly. but the new project has more than 200 entities. The creation of modules and lazy loading depends on the settings made by the client and their entities.
I would not want to separate in several applications because there is a lot of dependency. (200 services, 600 components)
The project runs fine with ng serve, but not with ng build. I rented a virtual machine with 28Gb ram and believe me, did the build using 27Gb of RAM. The service node occupied exactly 27Gb.
(I put the limit of 28gb)
Everything works fine with ng serve.
can anyone know to tell me if just separating into several lazy loading modules it will need less memory to compile with ng build? or it works only to separate the JS?
I can not rent a virtual machine whenever I need to run ng build. And the effort of change will be very high. So I needed to be sure of what to do.
Thanks.
@Tolitech Instead of depending on having enough RAM for this to build, just add swap to your machine. The build will be a little slower, but you don't need to be renting machines with 28 GB of RAM.
I too want this to be resolved ASAP, but adding swap space gets around the memory issue.
@joecot Thank you. I'll try to do this and see if it works. If it works, I do not see any problems if it takes 8 hours. I leave a night job for publication without problems.
That was a good idea. I'll try.
Thank you.
@joecot @notsonotso It worked. I configured 32Gb virtual memory (swap), --max_old_space_size and finally worked. It used the 28gb (It's too high), but it worked. Thank you very much for the idea, @joecot
@mhevery @bradlygreen - apologies for pulling you into this one, but with @Tolitech's extreme case above, the value proposition of Angular is starting to become seriously undermined.
Our codebase is growing rapidly, and our team is continuously running into these memory issues, where we even reach the limitations of our development and build machines. In all my years of web development there's never been a case that I would run out of the capabilities of the machine, just to compile to several 300k files for my webapp/website. It seems to be a memory optimization or architectural issue that hopefully can be avoided.
We've already lost countless hours on these problems, and the premise that Angular is a framework that scales for large enterprise applications doesn't hold up anymore.
I'd really appreciate if this issue could be prioritized, as I'm really starting to doubt whether our choice of Angular as a suitable framework was correct, considering that only the AOT builds are performant and small enough to ship to customers over the wire, and that we're struggling to get those to work. Thank you.
@bgever Apparently google is not using angular-cli/webpack themselves, so they don't run into problems like this. I suspect this is why this problem receives so little attention from the angular developers. If this continues, the community should be publicly warned about angular being unsuitable for large projects.
You were perfect in your words, @bgever . I'm already thinking that Angular does not work for large applications, after all I'm now needing 28 Gb of RAM and the project could grow bigger. (This is the first day of this application).
I'm already thinking about another strategy for this type of project, maybe even change technology because I'm realizing that this problem is occurring with many people and for a long time.
I believe my customer will not accept me saying that he needs 28 Gb RAM to compile his own project. I'm very worried about this.
I'm just staying in Angular CLI 1.2.7 while they fix this, hope they do it soon tho, but with 1.2.7 I have no memory problems at all.
Same here. Running Angular CLI 1.3.2 and Angular 4.3.6. Added this based on another thread to get it to work. My app isn't very big but CLI clocked in at 4GB to build my app.
"scripts": {
"build": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --target production --environment prod --aot",
"ng": "ng",
"start": "ng serve",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
@bjornharvold @Tolitech We need 1024go ram 32ghz cpu, so 32'000'000'000 calcul per second to build angular but if you learn bazel from google it can be faster 😂
https://github.com/endel/increase-memory-limit
This worked for me
Same problem here.
I had to downgrade to @angular/cli 1.2.6 with TS 2.4.2 for the build to work again.
A shame I can't use the latest angular cli ... Why isn't this considered a severe bug ?
@hugodes
Why isn't this considered a severe bug ?
I think it is because of https://github.com/angular/angular/issues/19058
Lastest version is the same !
Same here, this is ridiculous. I'm using a cheap VPS server to build and it simply crashes with 2GB of memory
What solved it for me was doing ng build --prod instead of ng build --aot --prod.
The --prod option already includes the --aot one, and optimises the build process and I'm not getting memory errors any more.
Hope it helps some of you guys.
Try -sm false
It happens to me when the allowJS parameter is true in tsconfig.json. Apparently, the javascript files are overloading the memory.
This worked for me, add to package.json scripts section. Watching the memory usage in task manager it got up to around 4gb usage. Seems a touch excessive!
"build2": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod --aot"
npm run build2
This command works for me: node --max-old-space-size=4096 ./node_modules/@angular/cli/bin/ng build --prod
"scripts":{ "prod": "node --max-old-space-size=4096 ./node_modules/@angular/cli/bin/ng build --prod" }
try process.nextTick() ?
With Node 8.x and latest cli version works without any hack :)
Sad to see that months have passed and this issue is still not solved. I'm having the same problem here:
´ ng build --aot
92% chunk asset optimization <--- Last few GCs --->
191455 ms: Mark-sweep 1296.7 (1433.7) -> 1291.4 (1434.7) MB, 1052.3 / 0.0 ms [allocation failure] [GC in old space request ed]. 192605 ms: Mark-sweep 1291.4 (1434.7) -> 1291.4 (1434.7) MB, 1150.6 / 0.0 ms [allocation failure] [GC in old space request ed]. 193711 ms: Mark-sweep 1291.4 (1434.7) -> 1294.8 (1403.7) MB, 1105.0 / 0.0 ms [last resort gc]. 194808 ms: Mark-sweep 1294.8 (1403.7) -> 1298.3 (1403.7) MB, 1097.0 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 00000146E3DCF791
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScrip t heap out of memory ´
I think this issue can be closed. Not because it's fixed, but because it will NOT be fixed. Not ever.
Google is busy trying to get a Bazel-based build system in place for public consumption, and they are unlikely to spend time fixing this old crap (it's mostly webpack's fault anyway)
Bug Report or Feature Request (mark with an
x
)Versions.
Repro steps.
ng build --prod --aot
The log given by the failure.
Desired functionality.
I would like to be able the app using AOT.
Mention any other details that might be useful.
I have tried changing
ng.cmd
to this:and
ngc.cmd
to:I have 8GB swap file. The build fails after 20-25 minutes standing on 92% progress.