node-red / linux-installers

Node-RED install scripts for various flavours of Linux
Apache License 2.0
94 stars 63 forks source link

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory #21

Closed tvan0076 closed 2 years ago

tvan0076 commented 2 years ago

All, Looking to see how to resolve my issue of not having enough memory in Node. I have large flows hosted on centOS and I have tried changing the memory settings, but that doesn't seem to work.

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

Are there any other ways to change these values from the install you put together? Log below

<--- JS stacktrace ---> FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0xa389b0 node::Abort() [node-red] 2: 0x96e0af node::FatalError(char const, char const) [node-red] 3: 0xbb7a4e v8::Utils::ReportOOMFailure(v8::internal::Isolate, char const, bool) [node-red] 4: 0xbb7dc7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate, char const, bool) [node-red] 5: 0xd73fd5 [node-red] 6: 0xd74b5f [node-red] 7: 0xd8299b v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node-red] 8: 0xd85e1f v8::internal::Heap::ReserveSpace(std::vector<v8::internal::Heap::Chunk, std::allocator >, std::vector<unsigned long, std::allocator >) [node-red] 9: 0x110a9e2 v8::internal::DeserializerAllocator::ReserveSpace() [node-red] 10: 0x11084e6 v8::internal::ContextDeserializer::Deserialize(v8::internal::Isolate, v8::internal::Handle, v8::DeserializeInternalFieldsCallback) [node-red] 11: 0x1108d84 v8::internal::ContextDeserializer::DeserializeContext(v8::internal::Isolate, v8::internal::SnapshotData const, bool, v8::internal::Handle, v8::DeserializeInternalFieldsCallback) [node-red] 12: 0x112f17a v8::internal::Snapshot::NewContextFromSnapshot(v8::internal::Isolate, v8::internal::Handle, unsigned long, v8::DeserializeInternalFieldsCallback) [node-red] 13: 0xe30388 v8::internal::Genesis::Genesis(v8::internal::Isolate, v8::internal::MaybeHandle, v8::Local, unsigned long, v8::DeserializeInternalFieldsCallback, v8::MicrotaskQueue) [node-red] 14: 0xe30738 v8::internal::Bootstrapper::CreateEnvironment(v8::internal::MaybeHandle, v8::Local, v8::ExtensionConfiguration, unsigned long, v8::DeserializeInternalFieldsCallback, v8::MicrotaskQueue) [node-red] 15: 0xbccf42 v8::NewContext(v8::Isolate, v8::ExtensionConfiguration, v8::MaybeLocal, v8::MaybeLocal, unsigned long, v8::DeserializeInternalFieldsCallback, v8::MicrotaskQueue) [node-red] 16: 0xbcd694 v8::Context::New(v8::Isolate, v8::ExtensionConfiguration, v8::MaybeLocal, v8::MaybeLocal, v8::DeserializeInternalFieldsCallback, v8::MicrotaskQueue) [node-red] 17: 0xa2953e node::contextify::ContextifyContext::CreateV8Context(node::Environment, v8::Local, node::contextify::ContextOptions const&) [node-red] 18: 0xa29b45 node::contextify::ContextifyContext::ContextifyContext(node::Environment, v8::Local, node::contextify::ContextOptions const&) [node-red] 19: 0xa29f26 node::contextify::ContextifyContext::MakeContext(v8::FunctionCallbackInfo const&) [node-red] 20: 0x13ddced [node-red] Process 1143 (node-red) of user 0 dumped core. nodered.service: Main process exited, code=dumped, status=6/ABRT nodered.service: Failed with result 'core-dump'.

dceejay commented 2 years ago

Not sure what you mean - you can manually change it to whatever value you want. 8192 is 8GB so either you have massive flow running some huge objects or you have some process running out of control and eating it all up before the garbage collector can kick in. Maybe you need to characterise your workload some more ? and indeed how much physical memory does your machine have (that you have access to).

tvan0076 commented 2 years ago

Yes, I have large flows, and most of the flows are copied 15 times to work for 15 different people with a lot of sub-flows. (one flow per person but all share many sub-flows). The server has 296Gig RAM and I have given Node-Red 16Gig. Running on VMWARE and Centos. I have tried to change the NODE_OPTIONS but that doesn't seem to do anything: (where is the best place to change this option?)

NODE_OPTIONS="--max-old-space-size=8192"

When I delete some unused flows the server comes back up. So, I must be hitting a limit somewhere. Crashes right after starting, and ALL my flows only run every 10 minutes.

tvan0076 commented 2 years ago

I was able to fix the issue by changing the /etc/systemd/system/nodered.service to add the Environment="NODE_OPTIONS=--max_old_space_size=8192"

Thanks all!!