Open3

next.js export default周りでメモリリークする件

こんな感じでimportしたのをそのままexport defaultでページ化したらメモリリーク発生

import { getProps, SomePage } from "../../components/pages/SomePage"

export const getServerSideProps = async (ctx) => {
  const props = await getProps(ctx.query)
  return props
}

// ↓激重メモリリークする
// export default SometPage

// ↓これなら大丈夫
export default (props) => <SomePage {...props} />

$ next build
info  - Using webpack 4. Reason: future.webpack5 option not enabled https://nextjs.org/docs/messages/webpack5
info  - Checking validity of types
info  - Creating an optimized production build ...
<--- Last few GCs --->

[14573:0x104615000]   175827 ms: Mark-sweep (reduce) 1978.4 (2074.2) -> 1978.3 (2075.0) MB, 535.9 / 0.0 ms  (average mu = 0.847, current mu = 0.009) allocation failure scavenge might not succeed
[14573:0x104615000]   176400 ms: Mark-sweep (reduce) 1979.3 (2075.0) -> 1979.2 (2076.0) MB, 567.0 / 0.0 ms  (average mu = 0.728, current mu = 0.009) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
 1: 0x1000ad6ac node::Abort() [/usr/local/Cellar/node/15.7.0/bin/node]
 2: 0x1000ad822 node::OnFatalError(char const*, char const*) [/usr/local/Cellar/node/15.7.0/bin/node]
 3: 0x1001e8691 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/Cellar/node/15.7.0/bin/node]
 4: 0x1001e863b v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/Cellar/node/15.7.0/bin/node]
 5: 0x10032d0ff v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/Cellar/node/15.7.0/bin/node]
 6: 0x100366fb8 v8::internal::EvacuateNewSpaceVisitor::Visit(v8::internal::HeapObject, int) [/usr/local/Cellar/node/15.7.0/bin/node]
 7: 0x100356acd void v8::internal::LiveObjectVisitor::VisitBlackObjectsNoFail<v8::internal::EvacuateNewSpaceVisitor, v8::internal::MajorNonAtomicMarkingState>(v8::internal::MemoryChunk*, v8::internal::MajorNonAtomicMarkingState*, v8::internal::EvacuateNewSpaceVisitor*, v8::internal::LiveObjectVisitor::IterationMode) [/usr/local/Cellar/node/15.7.0/bin/node]
 8: 0x1003566bb v8::internal::FullEvacuator::RawEvacuatePage(v8::internal::MemoryChunk*, long*) [/usr/local/Cellar/node/15.7.0/bin/node]
 9: 0x1003563ca v8::internal::Evacuator::EvacuatePage(v8::internal::MemoryChunk*) [/usr/local/Cellar/node/15.7.0/bin/node]
10: 0x100369d29 v8::internal::PageEvacuationTask::ProcessItems() [/usr/local/Cellar/node/15.7.0/bin/node]
11: 0x100369cc4 v8::internal::PageEvacuationTask::RunInParallel(v8::internal::ItemParallelJob::Task::Runner) [/usr/local/Cellar/node/15.7.0/bin/node]
12: 0x10033f630 v8::internal::ItemParallelJob::Task::RunInternal() [/usr/local/Cellar/node/15.7.0/bin/node]
13: 0x10033f9b6 v8::internal::ItemParallelJob::Run() [/usr/local/Cellar/node/15.7.0/bin/node]
14: 0x100358051 void v8::internal::MarkCompactCollectorBase::CreateAndExecuteEvacuationTasks<v8::internal::FullEvacuator, v8::internal::MarkCompactCollector>(v8::internal::MarkCompactCollector*, v8::internal::ItemParallelJob*, v8::internal::MigrationObserver*, long) [/usr/local/Cellar/node/15.7.0/bin/node]
15: 0x100357e2e v8::internal::MarkCompactCollector::EvacuatePagesInParallel() [/usr/local/Cellar/node/15.7.0/bin/node]
16: 0x10034b87e v8::internal::MarkCompactCollector::Evacuate() [/usr/local/Cellar/node/15.7.0/bin/node]
17: 0x100349726 v8::internal::MarkCompactCollector::CollectGarbage() [/usr/local/Cellar/node/15.7.0/bin/node]
18: 0x10032d681 v8::internal::Heap::MarkCompact() [/usr/local/Cellar/node/15.7.0/bin/node]
19: 0x10032b92d v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/Cellar/node/15.7.0/bin/node]
20: 0x10032a1f3 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/Cellar/node/15.7.0/bin/node]
21: 0x100332fc2 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/Cellar/node/15.7.0/bin/node]
22: 0x10033301a v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/Cellar/node/15.7.0/bin/node]
23: 0x10030c30e v8::internal::FactoryBase<v8::internal::Factory>::NewRawTwoByteString(int, v8::internal::AllocationType) [/usr/local/Cellar/node/15.7.0/bin/node]
24: 0x1006098d6 v8::internal::IncrementalStringBuilder::Extend() [/usr/local/Cellar/node/15.7.0/bin/node]
25: 0x1003f5820 v8::internal::JsonStringifier::SerializeString(v8::internal::Handle<v8::internal::String>) [/usr/local/Cellar/node/15.7.0/bin/node]
26: 0x1003f9354 v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<true>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [/usr/local/Cellar/node/15.7.0/bin/node]
27: 0x1003f80b6 v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<false>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [/usr/local/Cellar/node/15.7.0/bin/node]
28: 0x1003f38a5 v8::internal::JsonStringifier::Stringify(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [/usr/local/Cellar/node/15.7.0/bin/node]
29: 0x1003f37f0 v8::internal::JsonStringify(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [/usr/local/Cellar/node/15.7.0/bin/node]
30: 0x100269baf v8::internal::Builtin_Impl_JsonStringify(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/Cellar/node/15.7.0/bin/node]
31: 0x100838e19 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/usr/local/Cellar/node/15.7.0/bin/node]
error Command failed with signal "SIGABRT".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ログインするとコメントできます