"JavaScript heap out of memory" error occurs when build with lot of sub packages
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Description
“JavaScript heap out of memory” error occurs when building with 15+ subpackages.
Here is console output and error reports
https://gist.github.com/johnny-mh/897f377424013e7f4b7048971c121b96
This project build successfully with angular7 versions
// angular 7 (works fine)
$ node_modules/.bin/ng-packagr --version
ng-packagr: 4.4.0
@angular/compiler: 7.0.1
rollup: 0.66.6
tsickle: 0.33.1
typescript: 3.1.3
How To Reproduce
Build library with many sub packages.
Expected Behaviour
Expect the build to work even with very many secondary-entrypoints
Version Information
$ node_modules/.bin/ng-packagr --version
ng-packagr: 5.3.0
@angular/compiler: 8.0.2
rollup: 1.16.2
tsickle: 0.35.0
typescript: 3.4.5
package.json
{
"name": "@commerce-ui/ng-modules",
"version": "0.0.0-PLACEHOLDER",
"peerDependencies": {
"@angular/common": "^8.0.1",
"@angular/core": "^8.0.1",
"@commerce-ui/util": "^2.4.0",
"lodash": "^4.17.11"
},
"dependencies": {
"@egjs/agent": "^2.1.5",
"@egjs/flicking": "^2.5.1",
"billboard.js": "^1.9.2",
"@commerce-ui/legacy-lib": "0.0.6"
}
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:15 (3 by maintainers)
Top Results From Across the Web
How to Fix JavaScript Heap Out of Memory Error - MakeUseOf
This error usually occurs when the default memory allocated by your system to Node. js is not enough to run a large project....
Read more >How to solve JavaScript heap out of memory error
To fix JavaScript heap out of memory error, you need to add the --max-old-space-size option when running your npm command. Here's an example...
Read more >JavaScript heap out of memory in Angular 11 while ng serve ...
I found this error comes from the generation of source maps. Disabling source maps will make the error go away.
Read more >JavaScript Heap Out Of Memory Error | Felix Gerschau
This error indicates high memory usage or a memory leak in your application. In this article, I cover different solutions to this problem....
Read more >3.2 Understand the OutOfMemoryError Exception
Cause: The detail message Java heap space indicates object could not be allocated in the Java heap. This error does not necessarily imply...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@johnny-mh please keep the issue open. I really think increasing the available memory is not good solution and ng-packagr should improve it’s memory usage.
I’ve investigated a little bit this issue and it seems the oldPrograms cache causing the memory issue.
With cache (original code): memory increase by about 300MiB / entry point and goes up to 6GiB at the end.
When I clear the oldProgram cache after the entry point is built: memory usage goes up to 1.5GiB at the end.
When I clear all the caches after the entry point is built: max memory usage is 1.2GiB and decrease to 300MiB at the end
Still working on the issue, but if you are willing to trade time for less memory usage then patch the
entry-point.transform.js
in yournode_modules
and run theng-packagr
directly withnode --expose-gc node_modules/.bin/ng-packagr
.You can use the patch-package to automatize the patching. It does not work without the manual gc call, the memory for oldPrograms cache will not be deallocated.