JS Out of Memory

What does this error means? I’m using render for free, I think i ran out of allowed memory.

<— Last few GCs —>

Jul 22 05:03:59 AM

Jul 22 05:03:59 AM[110:0x6a06650] 110103 ms: Mark-Compact (reduce) 252.0 (258.2) → 251.2 (258.5) MB, 3408.86 / 0.00 ms (average mu = 0.164, current mu = 0.056) allocation failure; scavenge might not succeed

Jul 22 05:03:59 AM[110:0x6a06650] 113200 ms: Mark-Compact (reduce) 252.3 (258.5) → 251.5 (258.7) MB, 2902.83 / 0.00 ms (average mu = 0.117, current mu = 0.063) allocation failure; scavenge might not succeed

Jul 22 05:03:59 AM

Jul 22 05:03:59 AM

Jul 22 05:03:59 AM<— JS stacktrace —>

Jul 22 05:03:59 AM

Jul 22 05:03:59 AMFATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Jul 22 05:03:59 AM----- Native stack trace -----

Jul 22 05:03:59 AM

Jul 22 05:03:59 AM 1: 0xb84bd6 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]

Jul 22 05:03:59 AM 2: 0xefec30 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]

Jul 22 05:03:59 AM 3: 0xefef17 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]

Jul 22 05:03:59 AM 4: 0x1110925 [node]

Jul 22 05:03:59 AM 5: 0x1110eb4 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]

Jul 22 05:03:59 AM 6: 0x1127da4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node]

Jul 22 05:03:59 AM 7: 0x11285bc v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]

Jul 22 05:03:59 AM 8: 0x10fe8c1 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]

Jul 22 05:03:59 AM 9: 0x10ffa55 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]

Jul 22 05:03:59 AM10: 0x10dd0a6 v8::internal::factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]

Jul 22 05:03:59 AM11: 0x1537e36 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]

Jul 22 05:03:59 AM12: 0x1971ef6 [node]

Jul 22 05:03:59 AMAborted (core dumped)

Jul 22 05:04:01 AM==> Exited with status 134

Hi there,

It seems you are running tsc when you start your service. You should run this as part of your build as you don’t need to compile your Typescript every time you start your service.

I would also recommend adding export NODE_OPTIONS=--max-old-space-size=420 to your start command to set how much memory NodeJS will allocate to its heap size.

Regards,

Keith
Render Support, UTC+10 :australia:

Thank you very much, i did not even understand how much compiling typescript could cost to my program. i have one more question:

How should i put my start command: it says that’s a bad variable name?

Jul 23 06:11:53 AM> export NODE_OPTIONS=–max-old-space-size=420 node dist/app.js

Jul 23 06:11:53 AM

Jul 23 06:11:53 AMsh: 1: export: dist/app.js: bad variable name

Hi there,

Make the command export NODE_OPTIONS=–max-old-space-size=420 && node dist/app.js.

Regards,

Keith
Render Support, UTC+10 :australia:

2 Likes

Hey! I have the same problem in my MacBook Pro M2.

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

I’m running a easy process with Flowise (ChatOpenAI, gpt4omini - Buffer Memory - Conversation Chain).

Can you help me please?

Thanks a lot :slight_smile:

HI there,

If you are hitting heap space memory issues on your local machine which has access to much larger pools of memory, then you likely need to look into how your service allocates memory.

Regards,

1 Like

Thank you for your response!

As far as I understand it’s a memory usage problem in Flowise, not in Render, right? In this case, could you tell me how to solve it?

I appreciate your help Keith.

Kind Regards,
Salva

Hi there,

Correct, issues with heap allocation are a service level issue (i.e. Flowiser) not specifically a Render issue. You aren’t exceeding our memory limits in this case. Setting --max-old-space-size is one way to configure your service so as not to exceed the memory limits we impose. Seeing Flowise is run through Docker, it is not as simple as adding NODE_OPTIONS on the start command, as this is controlled through the Dockerfile. You would need to follow up with Flowise directly on how they would recommend setting --max-old-space-size.

You can do it through an environment variable, but this can also be applied to builds where you have different memory limits (build instances get 8GB of memory). I have a script here that sets --max-old-space-size dynamically based on the available memory of the instance. You would use this something like ./``max-old-space-size.sh`` && npm install && npm run build for builds and ./``max-old-space-size.sh`` && npm start for the start command.

Regards,

Still not working…On the first interaction with the flowise bot, it disconnects from rendering.

I’m use chatflows, simple process. I don’t know what is the problem because this process is light.

I have also created in my flowise folder two new scripts but it doesn’t work either, the same error log is displayed in memory.

#!/bin/bash
node --max-old-space-size=2048 dist/index.js

#!/bin/bash
export NODE_OPTIONS="–max-old-space-size=4096”

Thanks a lot for your support.

Kind Regards,
Salva

Hi there,

Those scripts will not run unless you call them from your Dockerfile.

Regards,

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