Cannot listen to localhost, heap out of memory

612 Views Asked by At

My setup

OS: Linux Mint 20.1 x86_64

node version: v14.16.1

Firstly I cloned the project with git.

Then install the deps with npm install

After that I run the server with npm run dev, but the server is hanging and couldn't listen to localhost:3000

> [email protected] dev /home/roby/web
> sapper dev

After I wait for about 4-5mins this error happened.

<--- Last few GCs --->

[1913:0x62fb080]   239094 ms: Scavenge (reduce) 946.8 (954.8) -> 946.2 (954.8) MB, 7.4 / 0.0 ms  (average mu = 0.287, current mu = 0.210) allocation failure 
[1913:0x62fb080]   239166 ms: Scavenge (reduce) 946.8 (952.0) -> 946.5 (953.5) MB, 20.0 / 0.0 ms  (average mu = 0.287, current mu = 0.210) allocation failure 
[1913:0x62fb080]   240769 ms: Mark-sweep (reduce) 947.3 (955.5) -> 945.5 (955.5) MB, 1542.4 / 0.1 ms  (average mu = 0.234, current mu = 0.173) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xa04200 node::Abort() [node]
 2: 0x94e4e9 node::FatalError(char const*, char const*) [node]
 3: 0xb7978e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xb79b07 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xd34395  [node]
 6: 0xd34f1f  [node]
 7: 0xd42fab v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 8: 0xd46b6c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 9: 0xd0c472 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node]
10: 0xd062f4 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [node]
11: 0xd08641 v8::internal::FactoryBase<v8::internal::Factory>::NewRawTwoByteString(int, v8::internal::AllocationType) [node]
12: 0xd0b1e5 v8::internal::FactoryBase<v8::internal::Factory>::NewConsString(v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, v8::internal::AllocationType) [node]
13: 0x1098490 v8::internal::Runtime_StringAdd(int, unsigned long*, v8::internal::Isolate*) [node]
14: 0x1401219  [node]
Aborted (core dumped)
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! [email protected] dev: `sapper dev`
npm ERR! Exit status 134
npm ERR! 
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/roby/.npm/_logs/2021-09-13T12_20_18_036Z-debug.log

I already tried npm package called increase-memory-limit in order to increase the memory limit but it didn't work. I also tried this command but still failed set NODE_OPTIONS=--max_old_space_size=4096

1

There are 1 best solutions below

1
Rahul On

Try this

export NODE_OPTIONS="--max-old-space-size=5120"

or use the one you mention with a export keyword

export set NODE_OPTIONS=--max_old_space_size=4096