question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Causes webpack to run out of heap when building

See original GitHub issue

Hi there.

When I include your plugin in my webpack.config.js file and run build I get a Javascript heap out of memory exception.

When I provide the --max_old_space_size argument and give it 10GB of ram it just builds to what seems infinity.

Stacktrace: WEBPACK_ENV=build webpack

Warning (worker-plugin): output.globalObject is set to “window”. It must be set to “self” to support HMR in Workers. [BABEL] Note: The code generator has deoptimised the styling of /home/daniel/Documents/Dynex/Canvas/canvas.iron.js/src/components/data/changeFocusHolder.js as it exceeds the max of 500KB.

<— Last few GCs —> art of marking 194 ms) (average mu = 0.198, current mu = 0.079) allocation[10962:0x3598210] 290153 ms: Mark-sweep 2045.5 (2052.8) -> 2043.0 (2050.6) MB, 163.7 / 0.0 ms (+ 0.0 ms in 31 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 178 ms) (average mu = 0.144, current mu = 0.079) allocation[10962:0x3598210] 290433 ms: Mark-sweep 2043.0 (2050.6) -> 2043.0 (2050.6) MB, 248.2 / 0.0 ms (average mu = 0.126, current mu = 0.113) allocation failure GC in old space requested

<— JS stacktrace —>

==== JS stack trace =========================================

0: ExitFrame [pc: 0x13162b9]
1: StubFrame [pc: 0x13718dc]

Security context: 0x35a54a940911 <JSObject> 2: walkExpressions [0x2d890b3a71d1] [/home/daniel/Documents/Dynex/Canvas/canvas.iron.js/node_modules/webpack/lib/Parser.js:1475] [bytecode=0x20b4258b8f81 offset=69](this=0x29546e2436a1 <Tapable map = 0x2aacf349e8b9>,0x3fec23d59ed9 <JSArray[1]>) 3: walkCallExpression [0x2d890b3a76a1] [/home/daniel/Documents/Dynex/Canvas/can…

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0x9aedf0 node::Abort() [node] 2: 0x9aff86 node::OnFatalError(char const*, char const*) [node] 3: 0xb078ce v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node] 4: 0xb07c49 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node] 5: 0xce4ae5 [node] 6: 0xcf032b v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node] 7: 0xcf1047 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node] 8: 0xcf3b78 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node] 9: 0xcc1b5f v8::internal::Factory::NewByteArray(int, v8::internal::AllocationType) [node] 10: 0xc4419a v8::internal::TranslationBuffer::CreateByteArray(v8::internal::Factory*) [node] 11: 0x191fe07 v8::internal::compiler::CodeGenerator::GenerateDeoptimizationData() [node] 12: 0x1920502 v8::internal::compiler::CodeGenerator::FinalizeCode() [node] 13: 0x1993abd v8::internal::compiler::PipelineImpl::FinalizeCode(bool) [node] 14: 0x1994b60 v8::internal::compiler::PipelineCompilationJob::FinalizeJobImpl(v8::internal::Isolate*) [node] 15: 0xc06ea0 v8::internal::Compiler::FinalizeOptimizedCompilationJob(v8::internal::OptimizedCompilationJob*, v8::internal::Isolate*) [node] 16: 0xc00766 v8::internal::OptimizingCompileDispatcher::InstallOptimizedFunctions() [node] 17: 0xc8ae5c v8::internal::StackGuard::HandleInterrupts() [node] 18: 0xf93ba7 v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) [node] 19: 0x13162b9 [node] Aborted (core dumped) npm ERR! code ELIFECYCLE npm ERR! errno 134 npm ERR! canvas.iron@1.0.85 build: WEBPACK_ENV=build webpack --max_old_space_size=10000 npm ERR! Exit status 134 npm ERR! npm ERR! Failed at the canvas.iron@1.0.85 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/daniel/.npm/_logs/2019-07-05T11_46_34_789Z-debug.log

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:19
  • Comments:14

github_iconTop GitHub Comments

1reaction
kfeinUIcommented, Jul 17, 2019

Ran into this as well. Worked fine a very simple test case while proving out my config. However, quickly scaling up to something much more sizeable and complex (trying to migrate existing stuff over to a worker) would just stall out.

Had just as much luck with worker-loader, so you’re in good company. Doesn’t seem terribly active though.

That the plugins aren’t applied consistently seems strange too. Maybe I’m over simplifying it, but I would think that this is a matter of dynamically generating a new entry point with a worker target. Webpack should in theory be able to cope with that like another.

0reactions
Tofandelcommented, Sep 22, 2021

I had the same issue after messing around with node version, webpack build stuck at 28% and eventually crashing out of memory, I solved it by removing the node_modules folder and the rerunning npm install, the heap issue was then gone

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack out of memory - Stack Overflow
The issue is caused by a memory leak in postcss-loader. The one liner below has worked for some. rm -rf [package-lock.json] node_modules &&...
Read more >
Fix out-of-memory issues during webpack compile - GitLab
The webpack config may be running into memory issues in part because it is taking on unnecessary responsibilities. The compression of assets ...
Read more >
Build Performance - webpack
Smaller = Faster. Decrease the total size of the compilation to increase build performance. Try to keep chunks small. Use fewer/smaller libraries.
Read more >
How to Fix JavaScript Heap Out of Memory Error - MakeUseOf
If you're running a relatively-large project, it may require more memory than the default allocated chunk. This may cause your project to crash ......
Read more >
JavaScript heap out of memory when running a react app
But there are times it can cause few issues due to the… ... Out of Memory issue while building node application on a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found