muon-protocol / muon-node-js

9 stars 18 forks source link

JavaScript heap out of memory #356

Closed sadeghte closed 9 months ago

sadeghte commented 10 months ago

After a while, this error causes the node to crash:

2023-11-02 05:27: 
2023-11-02 05:27: <--- Last few GCs --->
2023-11-02 05:27: 
2023-11-02 05:27: [174708:0x6a638d0] 329261681 ms: Mark-sweep 2784.7 (3107.1) -> 2769.2 (3107.8) MB, 3981.9 / 0.0 ms  (average mu = 0.111, current mu = 0.021) task; scavenge might not succeed
2023-11-02 05:27: [174708:0x6a638d0] 329265681 ms: Mark-sweep 2785.4 (3108.1) -> 2768.8 (3108.3) MB, 3901.1 / 0.0 ms  (average mu = 0.070, current mu = 0.025) allocation failure; scavenge might not succeed
2023-11-02 05:27: 
2023-11-02 05:27: 
2023-11-02 05:27: <--- JS stacktrace --->
2023-11-02 05:27: 
2023-11-02 05:27: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
2023-11-02 05:27:  1: 0xb83f50 node::Abort() [node]
2023-11-02 05:27:  2: 0xa94834  [node]
2023-11-02 05:27:  3: 0xd647c0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
2023-11-02 05:27:  4: 0xd64b67 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
2023-11-02 05:27:  5: 0xf42265  [node]
2023-11-02 05:27:  6: 0xf43168 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
2023-11-02 05:27:  7: 0xf53673  [node]
2023-11-02 05:27:  8: 0xf544e8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
2023-11-02 05:27:  9: 0xf2ee4e v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
2023-11-02 05:27: 10: 0xf30217 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
2023-11-02 05:27: 11: 0xf113ea v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
2023-11-02 05:27: 12: 0x12d674f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
2023-11-02 05:27: 13: 0x17035b9  [node]
bakhshandeh commented 10 months ago

node_283895

This is the chart of memory usage for a deployer node on PION.

bakhshandeh commented 10 months ago

This is the chart for a deployer node: image

and this one for a non deployer node: image

bakhshandeh commented 10 months ago

Memory usage is going too high when there are a lot of open connections in libp2p. We need to prune the connections. There is an issue here: https://github.com/muon-protocol/muon-node-js/issues/188

bakhshandeh commented 9 months ago

Pruning connections will fix this issue