webpack: Segmentation faults keep occurring after a while.
Bug report
What is the current behavior? After a while of running the webpack dev server in watch mode, webpack 5 segfaults with a message like this:
<--- Last few GCs --->
[44446:0x2a53fb0] 7749337 ms: Mark-sweep 1374.2 (1441.4) -> 1359.6 (1441.9) MB, 219.9 / 0.0 ms (average mu = 0.194, current mu = 0.102) allocation failure scavenge might not succeed
[44446:0x2a53fb0] 7749600 ms: Mark-sweep 1374.8 (1442.9) -> 1360.7 (1443.4) MB, 183.2 / 0.0 ms (average mu = 0.249, current mu = 0.304) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x3376821dbe1d]
1: StubFrame [pc: 0x3376821dd3a6]
Security context: 0x127c2a29e6c1 <JSObject>
2: SourceMapGenerator_serializeMappings [0x12508177b811] [/var/www/wordpress/current/tsi/admin/portal/build/node_modules/webpack-sources/node_modules/source-map/lib/source-map-generator.js:~312] [pc=0x33768705556d](this=0x102c5a302201 <SourceMapGenerator map = 0x22a5f09e6491>)
3: SourceMapGenerator_toJSON [0x1250...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x8fb090 node::Abort() [webpack]
2: 0x8fb0dc [webpack]
3: 0xb0322e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [webpack]
4: 0xb03464 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [webpack]
5: 0xef74c2 [webpack]
6: 0xef75c8 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [webpack]
7: 0xf036a2 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [webpack]
8: 0xf03fd4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [webpack]
9: 0xf06c41 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [webpack]
10: 0xed00c4 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [webpack]
11: 0x117024e v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [webpack]
12: 0x3376821dbe1d
Aborted (core dumped)
It seems to be running out of memory, but I am not sure why. I have recently migrated my project from webpack 4 to 5. On webpack 4, I never experienced segfaults at all. On webpack 5, after a while, it will try to compile and segfault as shown above.
If the current behavior is a bug, please provide the steps to reproduce. I’m not sure how to reproduce this outside of my project. The project is large (webpack reports producing around 16MB of js). If it’s an issue of memory not being freed, trying it with a similarly large project in watch mode should yield similar results.
What is the expected behavior? It shouldn’t segfault…
Other relevant information: webpack version: 5.24.4 Node.js version: 10.21.0 Operating System: Ubuntu 16.04 running inside of a docker container on Arch Linux Additional tools:
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 56 (39 by maintainers)
Node.js memory is limited by default to 1.4/2GB. You can increase it with
node --max-old-space-size=4196 node_modules/webpack/bin/webpack.js ...
orcross-env NODE_OPTIONS=--max-old-space-size=4196 webpack
Hard to say… maybe you can profile memory, so we can search leaks?
Can you try comment non official webpack plugins? Maybe leaking somewhere in these packages
@Hypnosphi Can you try
webpack
v5.30.0?@alexander-akait I understand, I will follow up.
Yes, I’ll try increasing memory today and see how it holds up.
Thanks