minify: JavaScript heap out of memory
I am using this in a medium large React project as part of the Webpack flow. For compression we are using the Babili-Webpack-Plugin. As this is just a small wrapper around Babili I figure the following issue is more related to Babili itself:
<--- Last few GCs --->
344958 ms: Mark-sweep 1324.0 (1434.9) -> 1324.0 (1434.9) MB, 1946.1 / 0.0 ms [allocation failure] [GC in old space requested].
346872 ms: Mark-sweep 1324.0 (1434.9) -> 1324.0 (1434.9) MB, 1913.9 / 0.0 ms [allocation failure] [GC in old space requested].
348780 ms: Mark-sweep 1324.0 (1434.9) -> 1327.8 (1405.9) MB, 1907.5 / 0.0 ms [last resort gc].
350727 ms: Mark-sweep 1327.8 (1405.9) -> 1331.7 (1405.9) MB, 1946.7 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x381e5ffcfb51 <JS Object>
1: visitQueue [/workspace/1_ui/ui-foundation/node_modules/babel-traverse/lib/context.js:~114] [pc=0x35f210c516c7] (this=0x2bf0d5c576b9 <a TraversalContext with map 0x22808a4e239>,queue=0x2bf0d5c57701 <JS Array[1]>)
2: node [/workspace/1_ui/ui-foundation/node_modules/babel-traverse/lib/index.js:~94] [pc=0x35f210cf29bc] (...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
3: v8::Utils::ReportApiFailure(char const*, char const*) [/usr/local/bin/node]
4: v8::Utils::ApiCheck(bool, char const*, char const*) [/usr/local/bin/node]
5: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
6: v8::internal::Factory::NewByteArray(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
7: v8::internal::Factory::NewCode(v8::internal::CodeDesc const&, unsigned int, v8::internal::Handle<v8::internal::Object>, bool, bool, int, bool) [/usr/local/bin/node]
8: v8::internal::PropertyAccessCompiler::GetCodeWithFlags(unsigned int, char const*) [/usr/local/bin/node]
9: v8::internal::PropertyHandlerCompiler::GetCode(v8::internal::Code::Kind, v8::internal::Code::StubType, v8::internal::Handle<v8::internal::Name>) [/usr/local/bin/node]
10: v8::internal::NamedLoadHandlerCompiler::CompileLoadNonexistent(v8::internal::Handle<v8::internal::Name>) [/usr/local/bin/node]
11: v8::internal::NamedLoadHandlerCompiler::ComputeLoadNonexistent(v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Map>) [/usr/local/bin/node]
12: v8::internal::LoadIC::UpdateCaches(v8::internal::LookupIterator*) [/usr/local/bin/node]
13: v8::internal::LoadIC::Load(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>) [/usr/local/bin/node]
14: v8::internal::Runtime_LoadIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
15: 0x35f20b8092a7
Abort trap: 6
These are the relevant software versions:
- Mac OS Sierra
- Node 6.9.2
- Babili Preset 0.0.9
- Babel Core 6.18.2
- Babel Traverse 6.19.0
Is there anything I can do to debug this anymore?
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 25
- Comments: 40 (8 by maintainers)
Still getting the same issue as of July/August - disabling mangle didn’t help.
same issue here
Still happening nowadays.
The issue was solved for me by turning off the option
mangle
. Please, fix this issue.@roman86 how do you run the node command? I see so many responses saying “use” --max-old-space-size=4076 but never seeing any instruction on how to “use” it. Would you mind providing me the direction please? Thanks!!
Just to add some information. I have been facing same issue. Interestingly we find one mistake we made in our code base. We have been using ‘babel-register’ in index.js which is responsible for dynamic loadings of file. By mistake we are trying to load compiled main.js bundle file using dynamic module. So, babel is parsing it again, finally running out of memory. Please make sure not to parse compiled version by babel. now it is working for us!
Same problem here with an
electron-webpack
app, also usingxlsx
as mentioned before. Setting--max_old_space_size=8192
also didn’t help.EDIT:
@taoabc @caesarsol I’m having similar problem with js-xlsx (~400kb file https://github.com/SheetJS/js-xlsx/blob/master/dist/xlsx.min.js)!
You can mitigate the memory/heap issue firing the webpack executable manually like this:
The real problem is CI services like travis are hanging anyway when the build takes more than 10mins (travis_wait does not work). Hoping for this pull request to be released soon to exclude it from the minification https://github.com/webpack-contrib/babel-minify-webpack-plugin/pull/75 🤞🏻
I had the same problem, I used :
node --max-old-space-size=4076 ...
and it finished.