AOT build fails due to "JavaScript heap out of memory"
Bug Report or Feature Request (mark with an x)
- [X ] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.0.0
node: 7.7.4
os: win32 x64
@angular/animations: 4.0.0
@angular/common: 4.0.0
@angular/compiler: 4.0.0
@angular/core: 4.0.0
@angular/flex-layout: 2.0.0-rc.1
@angular/forms: 4.0.0
@angular/http: 4.0.0
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 4.0.0
@angular/platform-browser-dynamic: 4.0.0
@angular/router: 4.0.0
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.0
Repro steps.
ng build --prod --aot
The log given by the failure.
/node_modules/@angular/material/aut 92% chunk asset optimization
<--- Last few GCs --->
[6328:0000016AB4D09F00] 1775597 ms: Mark-sweep 1411.2 (1513.5) -> 1411.0 (1513.5) MB, 1240.6 / 0.0 ms last resort
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0000034B0DD266A1 <JS Object>
2: optimize [0000000FABC02311 <undefined>:5480] [pc=00000082575652C8](this=000000633199A279 <an AST_Call with map 0000014753FA0291>,compressor=00000226DBDECA61 <a Compressor with map 0000032B1EC8F829>)
3: before [0000000FABC02311 <undefined>:5463] [pc=0000008258C1818D](this=00000226DBDECA61 <a Compressor with map 0000032B1EC8F829>,node=000000633199A279 <an AST_Call with map 0000014753...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
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:
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" --max_old_space_size=8192 "%~dp0\..\@angular\cli\bin\ng" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node --max_old_space_size=8192 "%~dp0\..\@angular\cli\bin\ng" %*
)
and ngc.cmd to:
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" --max_old_space_size=8192 "%~dp0\..\@angular\compiler-cli\src\main.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node --max_old_space_size=8192 "%~dp0\..\@angular\compiler-cli\src\main.js" %*
)
I have 8GB swap file. The build fails after 20-25 minutes standing on 92% progress.
@filipesilva I have updated the version and I'm still having the same problem :(
ng build --prod --aot
92% chunk asset optimization
<--- Last few GCs --->
[70119:0x103000800] 221253 ms: Mark-sweep 1412.4 (1539.6) -> 1412.4 (1527.1) MB, 2772.9 / 0.0 ms (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 2773 ms) last resort
[70119:0x103000800] 223828 ms: Mark-sweep 1412.4 (1527.1) -> 1412.4 (1527.1) MB, 2574.0 / 0.0 ms last resort
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x1174077a8799 <JSObject>
2: add_parameter [0x35ed60282311 <undefined>:2953] [bytecode=0x2a011d5e84c1 offset=69](this=0x1dee67b6c479 <Object map = 0x13abb57fc8b1>,token=0x3e75c751c6b9 <AST_Token map = 0x2edf31c836a1>)
4: binding_element(aka binding_element) [0x35ed60282311 <undefined>:3236] [bytecode=0x2a011d5e6669 offset=2234](this=0x35ed60282311 <undefined>,used_parameters=0x1dee67b6c479 <Object map = 0x13abb57...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Here are the versions which I'm using:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 1.5.2
Node: 8.5.0
OS: darwin x64
Angular: 5.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cdk: 5.0.0-rc0
@angular/cli: 1.5.2
@angular/flex-layout: 2.0.0-beta.10
@angular/material: 5.0.0-rc0
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.2
@schematics/angular: 0.1.5
typescript: 2.4.2
webpack: 3.8.1
If you give me enough instruction on how you debug the webpack build I can help find the source of the problem....
Can confirm that it's fixed the problem for us. Using 1.5.2 and Node 9.2.0 - no longer need to increase Node memory.
With the new 1.5.2 release, my memory problem and bundle size haven been fixed, it still takes some time stuck at the 92% but works in the end.
@seanlandsman I tested your repros again with --stack_size=512 and --stack-size=8048 and only saw memory consumption in the 400-500MB range. The default seems to be --stack_size=984 btw.
I did see something else though:
kamik@T460p MINGW64 /d/sandbox/memory/aggrid-1.5 (master)
$ npm run prod
> [email protected] prod D:\sandbox\memory\aggrid-1.5
> node --stack_size=512 ./node_modules/@angular/cli/bin/ng build --prod
Date: 2017-11-17T10:46:12.052Z
Hash: db122ac832a501fd0cf8
Time: 31443ms
chunk {0} main.67d8219d9d4c87c59477.bundle.js (main) 830 kB [initial] [rendered]
chunk {1} polyfills.e6475d2787bb3154d59c.bundle.js (polyfills) 61.1 kB [initial] [rendered]
chunk {2} styles.9b2fb464224d0a79781d.bundle.css (styles) 49 kB [initial] [rendered]
chunk {3} inline.d67e755da47b31497a24.bundle.js (inline) 1.45 kB [entry] [rendered]
ERROR in ./node_modules/ag-grid/dist/lib/gridOptionsWrapper.js
Module build failed: RangeError: Maximum call stack size exceeded
at getJSDocsWorker (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:8167:33)
at getJSDocs (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:8163:13)
at getJSDocTags (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:8148:27)
at getJSDocParameterTags (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:8213:20)
at Object.isRestParameter (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:8295:28)
at symbolToParameterDeclaration (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:29262:41)
at D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:29215:89
at Array.map (<anonymous>)
at signatureToSignatureDeclarationHelper (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:29215:55)
at createTypeNodeFromObjectType (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:29024:49)
at createAnonymousTypeNode (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:28988:42)
at typeToTypeNodeHelper (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:28938:28)
at createTypeNodesFromResolvedType (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:29177:67)
at createTypeNodeFromObjectType (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:29035:35)
at createAnonymousTypeNode (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:28988:42)
at typeToTypeNodeHelper (D:\sandbox\memory\aggrid-1.5\node_modules\typescript\lib\typescript.js:28938:28)
@ ./node_modules/ag-grid/dist/lib/columnController/columnUtils.js 11:27-59
@ ./node_modules/ag-grid/main.js
@ ./node_modules/ag-grid-angular/dist/ng2FrameworkFactory.js
@ ./src/app/app.component.ngfactory.js
@ ./src/app/app.module.ngfactory.js
@ ./src/main.ts
@ multi ./src/main.ts
This seems consistent with what --stack-size actually does (https://github.com/nodejs/node/issues/6360). It doesn't increase total available memory, but rather the the size of each stack region that node uses. It that increasing it can solve issues with a lot of recursion (but that code should try to not have that).
The symptoms seem to be different on OSX (memory bust) and Windows (maximum call stack size exceeded). I don't know why that is.
I think the problem you're experiencing is solely related to Build Optimizer as you posited, and is the one tracked in https://github.com/angular/devkit/issues/240. Still relevant for this thread mind you, but the specific issue is that one.
@changLiuUNSW were your build times with 1.4.x shorter, and if so, by how much?
@magemello I'll ping you on the gitter you provided and see what we can do in your project.
@filipesilva I do not have a chance to try 1.4.x because we used CLI 1.3.0 in our project before Angular CLI 1.3.0 with Angular 4.2.4
ng build --prod
[14:08:02][Step 4/15] Time: 236558ms
[14:08:02][Step 4/15] chunk {0} polyfills.6bb91be4d06bd2c9e250.bundle.js (polyfills) 217 kB {4} [initial] [rendered]
[14:08:02][Step 4/15] chunk {1} main.71c6b1116dc39af75599.bundle.js (main) 1.59 MB {3} [initial] [rendered]
[14:08:02][Step 4/15] chunk {2} styles.21cad12ac9e3527f0f7d.bundle.css (styles) 166 kB {4} [initial] [rendered]
[14:08:02][Step 4/15] chunk {3} vendor.dfcfc494ca724bf884bf.bundle.js (vendor) 653 kB [initial] [rendered]
[14:08:02][Step 4/15] chunk {4} inline.f1134fc323101279dbaf.bundle.js (inline) 1.46 kB [entry] [rendered]
Angular CLI 1.5.2 with Angular 5.0.1
ng build --prod
[22:20:39][Step 4/15] Time: 530465ms
[22:20:39][Step 4/15] chunk {0} polyfills.953b2ea9f096cadfdccc.bundle.js (polyfills) 147 kB [initial] [rendered]
[22:20:39][Step 4/15] chunk {1} main.e2cfa60d1ec303d72a6a.bundle.js (main) 1.77 MB [initial] [rendered]
[22:20:39][Step 4/15] chunk {2} styles.b49f8f5ee25381105567.bundle.css (styles) 108 kB [initial] [rendered]
[22:20:39][Step 4/15] chunk {3} inline.2ae12ef65c8a9f6162ba.bundle.js (inline) 1.49 kB [entry] [rendered]
I understand in 1.5, --build-optimize is enable by default for production build, but 5 minutes difference between 1.5 and 1.3 is not good.
@changLiuUNSW I agree 5 minutes difference is a long time. Can you try --build-optimizer=false for now please?
@filipesilva Angular CLI 1.5.2 with Angular 5.0.1
ng build --prod --build-optimizer=false
Time: 163265ms
chunk {0} polyfills.cdff46cd9b1a8d656218.bundle.js (polyfills) 147 kB [initial] [rendered]
chunk {1} main.d1916123bd0e4aa2858f.bundle.js (main) 1.34 MB [initial] [rendered]
chunk {2} styles.d1f7c9f576103c62cb95.bundle.css (styles) 108 kB [initial] [rendered]
chunk {3} vendor.1fbdf23b6f274bb4005e.bundle.js (vendor) 639 kB [initial] [rendered]
chunk {4} inline.58b71d550a47f85197a5.bundle.js (inline) 1.5 kB [entry] [rendered]
6 minutes difference with build-optimizer=true
Thank you @filipesilva for your help, I did the following:
- Set Angular dependencies to 5.0.2
- Set Angular CLI to 1.5.2
- Delete node_modules & package-lock.json
- npm install
and now the result is the following:
- npm run ng -- build works
- ng build --aot fails
- node --max_old_space_size=30000 node_modules/.bin/ng build --aot works
- ng build --prod --build-optimizer=false fails
- node --max_old_space_size=30000 node_modules/.bin/ng build --prod --build-optimizer=false works
- node --max_old_space_size=30000 node_modules/.bin/ng build --prod fails
So, in general raise the max_old_space_size fix my issue at exception of the "ng build --prod", in this case my problem seems to be related to this: https://github.com/angular/angular/issues/20115. In other words the problem seems to be the presence of ts files in my libraries and aot geting angry about it :), the solution for this point seems to be put ts file in the .npmignore and exclude it from the packages. (haven't test it yet)
I'm just reporting the finding, hopying it helps others....all the credit goes to @filipesilva.
@changLiuUNSW @Tolitech can I ask you to do some more advanced debugging if you have time? I don't have access to your projects but they seem good examples.
@changLiuUNSW Your project doesn't seem to have memory problems anymore but it is taking very long to build with Build Optimizer.
I think one of the build optimizer transformations is taking a very long time on your codebase, but I can't know which ones. I can tell you how to disable each one individually though.
You can do this in ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/build-optimizer.js. From line 63 to line 82, each transform is individually added to the getTransforms array. You can comment out each of the getTransforms.push( and that transform will not be added.
If you can do this for each one and time me how it impacts build time, I might be able to figure out which of the transforms is taking too long.
@Tolitech your project has problems with memory usage with 1.4.x, and you have already confirmed it does not use build optimizer. You reported that memory usage went up to 28gigs during a prod build.
I'd like to ask you to do a couple of things. First, can you tell me the memory usage of just ng build please?
Then, I'd like you to try to manually disable Uglify. This can be done in ./node_modules/@angular/cli/models/webpack-configs/production.js, line 111-117 (the new webpack.optimize.UglifyJsPlugin({ call). Comment those lines, and try to do a production build again (with increased memory limits). What was the maximum memory used?
I understand that debugging these things take time and appreciate that you take the time to do it. I'm doing the same things on projects I have access to but each project is different so it's very difficult to zone in on the exact issue without having access to the code. Asking you to do some tests is the next best thing.
Running ng build --aot --prod yielded the following
Date: 2017-11-17T18:23:24.062Z
Hash: 7dff5d083d5a19785434
Time: 558874ms
chunk {0} polyfills.e8bddc586f67afdffd0d.bundle.js (polyfills) 65.6 kB [initial] [rendered]
chunk {1} main.ba0bc9f17d63868a89a3.bundle.js (main) 2.49 MB [initial] [rendered]
chunk {2} styles.cb450a88292b46f1511b.bundle.css (styles) 81 kB [initial] [rendered]
chunk {3} inline.0002f507274cf434cef2.bundle.js (inline) 1.45 kB [entry] [rendered]
took nearly 10 minutes but the build did complete and didn't exceed the 1.3GB RAM mark now. By the looks of it, the bundle also decreased in size. Before I was getting a main bundle of 1.98 MB and a vendor bundle of 1.51 MB and now I only seem to have a single main bundle of 2.49MB.
The dev bundle went from vendor 16MB and main 4.61MB to vendor 5.91MB and main 1.87MB and it didn't exceed the 800MB RAM mark.
This was generated with the following setup
Angular CLI: 1.5.2
Node: 6.11.0
OS: win32 x64
Angular: 5.0.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
@angular/cdk: 5.0.0-rc0
@angular/cli: 1.5.2
@angular/flex-layout: 2.0.0-beta.10-4905443
@angular/material: 5.0.0-rc0
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.2
@schematics/angular: 0.1.5
typescript: 2.6.1
webpack: 3.8.1
I'll update my node to the latest 8.* version and I'll see if this changes anything in terms of RAM consumption.
@filipesilva I was looking at the package.json for Angular:
"engines": {
"node": ">=6.9.5 <7.0.0",
"npm": ">=3.10.7 <4.0.0",
"yarn": ">=1.0.2 <2.0.0"
},
I've always taken the engines section to mean that those were the engines supported. Is running Node 8 officially supported or am I reading this all wrong?
Well, interestingly, node 8.9.1 did complete the bundle nearly twice as fast (~5min 50 seconds) compared to node 6.11 and it did use about ~150-200MB less ram throughout the final (92%-95%) stages of the process.
Date: 2017-11-17T20:14:47.417Z
Hash: fd0232ebf712617a9dad
Time: 351019ms
chunk {0} polyfills.e8bddc586f67afdffd0d.bundle.js (polyfills) 65.6 kB [initial] [rendered]
chunk {1} main.ba0bc9f17d63868a89a3.bundle.js (main) 2.49 MB [initial] [rendered]
chunk {2} styles.cb450a88292b46f1511b.bundle.css (styles) 81 kB [initial] [rendered]
chunk {3} inline.0002f507274cf434cef2.bundle.js (inline) 1.45 kB [entry] [rendered]
Angular CLI: 1.5.2
Node: 8.9.1
OS: win32 x64
Angular: 5.0.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
So although the compilation time reduction was very nice, the node version doesn't seem to play a major role in the RAM consumption issue (at least on my machine/project).
EDIT:
Running ng build --aot --prod --build-optimizer=false finished 3 times faster than ng build --aot --prod but it did use about 150-200MB more RAM.
Date: 2017-11-17T20:29:38.921Z
Hash: 94cb3178b3be74bd0397
Time: 126625ms
chunk {0} polyfills.e8bddc586f67afdffd0d.bundle.js (polyfills) 65.9 kB [initial] [rendered]
chunk {1} styles.cb450a88292b46f1511b.bundle.css (styles) 81 kB [initial] [rendered]
chunk {2} main.55c058ed7857dda94b2e.bundle.js (main) 1.8 MB [initial] [rendered]
chunk {3} vendor.ba5bb536a884f0ae6767.bundle.js (vendor) 1.33 MB [initial] [rendered]
chunk {4} inline.39aa19fa644263353f85.bundle.js (inline) 1.45 kB [entry] [rendered]
So all in all build optimizer seems to actually help RAM consumption at the expense of time.
Hello @filipesilva I've done some more tests and would like to share it with you.
To be a fair test, I restarted my laptop at all times when I changed a line in the production.js file and after running ng build -prod.
In all tests, the virtual memory added was 32 GB. The laptop has 8 GB physical RAM.
In the ng.cmd file the configured command was --max_old_space_size = 32768 in all cases.
It is important to remember that in this test, the total memory allocated is not exactly the total memory required by Node.js, since it would be the total used by the computer in all of its processes.
However, there was no program or process running, and in all tests the computer was restarted.
Let's go to the tests:
Test 1 Configuration:

Total memory allocated by the computer: 36.5 GB

Waiting time to complete: 26 min 24 secs
Test 2 Configuration:

Total memory allocated by the computer: 34 GB

Waiting time to complete: 20 min 52 secs
Test 3 Configuration:

Total memory allocated by the computer: 7.9 GB

Waiting time to complete: 10 min 03 secs
Test 4 Configuration:

Total memory allocated by the computer: 8.8 GB

Waiting time to complete: 13 min 59 secs
Node v8.9.1 Angular CLI 1.4.1
By my tests, I have to conclude that in my specific case, it is the new webpack.optimize.ModuleConcatenationPlugin() command line that is dramatically increasing my memory need.
With this line enabled, my consumption goes from 8.8 GB to 36.5 GB as indicated by the windows task manager.
If you need more tests, just give me instructions. I work more with .NET, but with instructions I believe I can test.
Thank you.
@Tolitech thanks lot for trying that! I think you're on to something.
The commit that introduced ModuleConcatenationPlugin was released in 1.3.0-rc.0 (https://github.com/angular/angular-cli/commit/fe85750cb7db699505faf1cc63e3d35018d47ed2).
This matches up with what @amikitevich @randyaa and @radoslavpetranov said: their memory problems started with 1.3.0.
Using ModuleConcatenationPlugin is important for two reasons:
- it makes javascript loading in the browser faster (https://medium.com/webpack/webpack-3-official-release-15fd2dd8f07b)
- it enables smaller bundles when used with Uglify and Build Optimizer
But it also seems to be causing excessive memory usage in some cases.
I'm a bit at a loss at what I can do about this now. ModuleConcatenationPlugin might use a lot of memory by design or it might just be a bug, but it's hard to tell without being able to test it myself.
To users that started having memory problems after the 1.3x update: can you try doing a build disabling ModuleConcatenationPlugin manually (same instructions as I gave @Tolitech in https://github.com/angular/angular-cli/issues/5618#issuecomment-345268174) and tell me if it helps? If it does help and your project is public, can you tell me where I can see it?
@Tolitech can you tell me which libraries you use in your app? Maybe I can try including them in a project and can reproduce it like that.
running ng build --aot --prod with new webpack.optimize.ModuleConcatenationPlugin() commented out
Date: 2017-11-19T08:34:58.624Z
Hash: 9c0b60b77822f45ea9fd
Time: 158811ms
chunk {0} main.dc03843e6c0ae1671bc2.bundle.js (main) 2.61 MB [initial] [rendered]
chunk {1} polyfills.a0160642e7aef2ebb253.bundle.js (polyfills) 65.6 kB [initial] [rendered]
chunk {2} styles.cb450a88292b46f1511b.bundle.css (styles) 81 kB [initial] [rendered]
chunk {3} inline.4c5cd4d92e0d15ed3e92.bundle.js (inline) 1.45 kB [entry] [rendered]
running ng build --aot --prod with new webpack.optimize.ModuleConcatenationPlugin() activated
Date: 2017-11-19T08:42:05.090Z
Hash: 8e9b1a1739224a7ca0ad
Time: 336440ms
chunk {0} polyfills.e8bddc586f67afdffd0d.bundle.js (polyfills) 65.6 kB [initial] [rendered]
chunk {1} main.4f0ad6b15ea65c6ef0b0.bundle.js (main) 2.49 MB [initial] [rendered]
chunk {2} styles.cb450a88292b46f1511b.bundle.css (styles) 81 kB [initial] [rendered]
chunk {3} inline.9ebe9dea2365b402bb45.bundle.js (inline) 1.45 kB [entry] [rendered]
No difference in RAM consumption on my project.
@filipesilva My project is public, and I am facing exactly the same issue after I upgrade Angular-CLI a few days ago. You can have a try on 'ng build -prod' via https://github.com/alvachien/achihui
@alvachien I tried your project with 1.5.2 and it ng build --prod built correctly with a peak of 1.2GB memory usage. Did you try 1.5.2? There's a fix there that isn't in 1.5.0.
@markmaynard what you're looking at is the the package.json for the angular/angular repo: https://github.com/angular/angular/blob/master/package.json#L10-L13. That repro is what we call a monorepo, where multiple packages are under the same repository. The engine requirements you see there are for the monorepro itself: the requirements to build the Angular packages. But not the requirements for using the Angular packages. If you check out package.json for @angular/core (in your node_modules for instance), there won't be any engine requirements.
@mattem @WandererInVoids I tried running a few experiments in a project with a lot of libs, to compare memory usage with and without a separate Uglify process:
ng build --prod: peak 1.1GB memory, 4.1MB main bundleng build --prodwith Uglify manually commented off: peak 0.8GB memory, 10.5MB main bundle- Uglify ran manually on main bundle: peak 0.7GB memory, 4.2MB uglified main bundle
CLI used was 1.5.2. It's important to note that I used the same Uglify we use in the CLI ([email protected], the one included by [email protected]), and that I also used the same flags we use in the CLI: --compress pure_getters,passes=3 --mangle.
Flags here are really important because these affect the memory usage and end result. See https://github.com/mishoo/UglifyJS2/issues/2113 for some conversation about memory usage in Uglify.
From the numbers I got I wouldn't say there is a problem with how we use Uglify. The difference (1.1GB vs 0.8+0.7) is larger than each process individually but is smaller than both together. I expect this to be because of all the files/sourcemaps loaded into memory.
But it's worth mentioning that by not running --prod you are also not running ModuleConcatenationPlugin. Maybe in your projects that's the actual problem and not Uglify. Can you try disabling as well? (see https://github.com/angular/angular-cli/issues/5618#issuecomment-345465395 on how to disable it).
Hello @filipesilva I have tried to create a very similar model of what I use so that the tests can be performed with greater precision.
In this application there are basically 5 main pages (category, status, severity, project and issue) that are replicated 10 times within the same module. We have 50 pages per module. 10 modules totaling 500 pages were created.
For me, a page is composed of 3 components, the entry point, the grid and the form. So we have 1,500 components created.
There are several other components created and used by the application, base components that are inherited via typescript, pagination, menu, security, shared module, directives, guards, models, resolvers, among other elements.
Not all npm referenced libraries are being used in this example, but I believe the model is quite useful for testing.
In this example, my maximum memory consumption hit 23 GB. Somewhat below my actual case, because although this example has many more components, the components created in my real case are more complex.

I do not know if I exaggerated the number of elements created for the test. Although hundreds of services have been created (one for each page), all modules and page replications call the same five Api urls (category, status, severity, project and issue).

Both the API and the angular project are published and working in: Api: http://clientes.tolitech.com.br/ngTestApi Api Documentation: http://clientes.tolitech.com.br/ngTestApi/api-docs Angular: http://clientes.tolitech.com.br/ngtest/
To download the source code: http://www.codegenerator.com.br/downloads/ng-test.zip

@Tolitech whoa this is perfect, thank you so much! I'll use it to run some benchmarks and see what I can find. Will also try and trim it down to do a webpack issue for ModuleConcatenationPlugin so we can get the ball rolling there. This is great!