How to Increase memory with mongosh?


I’m using mongosh
I got this error

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xaa5120 node::Abort() [mongosh ]
 2: 0x9d4035 node::FatalError(char const*, char const*) [mongosh ]
 3: 0xc23fde v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [mongosh ]
 4: 0xc24357 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [mongosh ]
 5: 0xddf895  [mongosh ]
 6: 0xde041f  [mongosh ]
 7: 0xdee4c3 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [mongosh ]
 8: 0xdf205c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [mongosh ]
 9: 0xdc090b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [mongosh ]
10: 0x110ae70 v8::internal::Runtime_AllocateInOldGeneration(int, unsigned long*, v8::internal::Isolate*) [mongosh ]
11: 0x14a96f9  [mongosh ]

Is there a setting in mongosh that I can use to increase the memory?


@fbenab You can use the NODE_OPTIONS environment variable to control this aspect of mongosh, e.g. env NODE_OPTIONS='--max-old-space-size=4096' mongosh runs mongosh with a heap size of 4GB.


@Anna_Henningsen Thanks so you don’t have any configuration file related to mongosh only the nodejs

@fbenab We do – has some information on that. But that’s only for the behavior of mongosh itself, not the platform on which it runs (Node.js).


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.