Javascript heap out of memory

Issue #14 new
Muhammed Shafi created an issue

Is there any limitation to the size of the openAPI specification that can be passed to this tool? I tried to get a diff by passing a considerably large specification and the tool resulted in a heap out of memory issue. The specification takes nearly more than 60, 000 lines swagger editor. Is there any way that I can get this tool work for such huge specifications? Thank you in advance!

Following is the error displayed,

<--- Last few GCs --->

[18416:000002609DB33100]    29919 ms: Mark-sweep 2047.0 (2055.3) -> 2045.5 (2051.8) MB, 2024.8 / 0.0 ms  (+ 242.9 ms in 48 steps since start of marking, biggest step 12.0 ms, walltime since start of marking 2294 ms) (average mu = 0.126, current mu = 0.031[18416:000002609DB33100]    32163 ms: Mark-sweep 2047.6 (2051.8) -> 2046.1 (2051.8) MB, 2130.3 / 0.0 ms  (+ 98.3 ms in 19 steps since start of marking, biggest step 12.6 ms, walltime since start of marking 2240 ms) (average mu = 0.068, current mu = 0.007)

<--- JS stacktrace --->

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

    0: ExitFrame [pc: 00007FF639B6A09D]
Security context: 0x02e358f808d1 <JSObject>
    1: /* anonymous */ [000003EF032BE6F1] [C:\OpenAPIDiff - Version_2\node_modules\openapi-diff\dist\openapi-diff\spec-parser\common\to-diff-compatible-json-schema.js:~48] [pc=0000035578DD495D](this=0x01b6af81c0e9 <Object map = 00000227491E38E9>,0x01c3ae9c7c19 <Object map = 00000285D4C4499...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF638F5538F napi_wrap+114751
 2: 00007FF638EFFE26 v8::base::CPU::has_sse+66646
 3: 00007FF638F00C26 v8::base::CPU::has_sse+70230
 4: 00007FF639715B3E v8::Isolate::ReportExternalAllocationLimitReached+94
 5: 00007FF6396FDC11 v8::SharedArrayBuffer::Externalize+833
 6: 00007FF6395C9E7C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1436
 7: 00007FF6395D50B0 v8::internal::Heap::ProtectUnprotectedMemoryChunks+1312
 8: 00007FF6395D1BD4 v8::internal::Heap::PageFlagsAreConsistent+3204
 9: 00007FF6395C73D3 v8::internal::Heap::CollectGarbage+1283
10: 00007FF6395C5A44 v8::internal::Heap::AddRetainedMap+2452
11: 00007FF6395E6D8D v8::internal::Factory::NewFillerObject+61
12: 00007FF63934CED1 v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=+1665
13: 00007FF639B6A09D v8::internal::SetupIsolateDelegate::SetupHeap+546637
14: 0000035578DD495D

node version - 12.18.2
openapi-diff version - 0.23.2

Comments (4)

  1. Ben Sayers

    To help us reproduce this issue and work out what the problem is can you share a bit more information, such as:

    • A spec that demonstrates this issue
    • The error output from the tool, including how big the heap was and where in the program it was executing at the time of the error
    • What nodejs version you are using
    • What version of openapi-diff you are using

    From memory the default size of the heap should be above 1GB, where as even the larger swagger specs I’ve seen are only 10-20MB. So from what I know so far it seems much more likely you’ve run into a bug than a size limitation with the tool.

  2. Muhammed Shafi Account Deactivated reporter

    Hi Ben,

    I have updated the issue with the details you requested. Would be a great help if you can go through it. And please let me know if you need further information. Thank you!

  3. Log in to comment