본문 바로가기

JavaScript

[Jenkins] Node.js의 가비지 컬렉션(GC) 메모리 부족 오류 해결하기

반응형

오류

Jenkins에서 Nuxt3 기반 Vue 프로젝트 빌드 시 Node.js의 가비지 컬렉션(GC) 관련 메모리 부족 경고가 발생하였다.

[info] [nitro] Building Nuxt Nitro server (preset: `node-server`)

<--- Last few GCs --->

[79870:0x70527f0]    56337 ms: Scavenge (reduce) 1807.1 (1846.7) -> 1806.4 (1846.9) MB, 3.33 / 0.00 ms  (average mu = 0.247, current mu = 0.243) allocation failure; 
[79870:0x70527f0]    56350 ms: Scavenge (reduce) 1808.1 (1847.7) -> 1807.4 (1848.2) MB, 10.02 / 0.00 ms  (average mu = 0.247, current mu = 0.243) allocation failure; 
[79870:0x70527f0]    56369 ms: Scavenge (reduce) 1809.1 (1848.7) -> 1808.4 (1848.9) MB, 15.64 / 0.00 ms  (average mu = 0.247, current mu = 0.243) allocation failure; 


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0xb84bd6 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
 2: 0xefec30 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 3: 0xefef17 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 4: 0x1110925  [node]
 5: 0x1110eb4 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
 6: 0x1127da4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node]
 7: 0x11285bc v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 8: 0x10fe8c1 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 9: 0x10ffa55 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
10: 0x10dd0a6 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
11: 0x1537e36 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x1971ef6  [node]

 

 

해결 방법

Jenkins에서 빌드할 때 Node.js의 메모리 한도를 늘리기:

  1. Jenkins의 해당 작업(Job) 설정
  2. Build Environment 섹션으로 이동
  3. "Inject environment variables to the build process" 체크박스 선택
  4. Properties Content 텍스트 영역에 다음을 추가:
NODE_OPTIONS=--max-old-space-size=4096

 

 

반응형