Out of memory error

Hi all,

I just deployed a service app for the first time on Render, and within minutes of playing around with the deployed website, I got an “Out of memory (used over 512MB)” error, with the following logs:

Jun 23 11:50:09 PM  [68:0x547f6d0]   377303 ms: Scavenge 246.4 (253.2) -> 245.6 (253.4) MB, 0.7 / 0.0 ms  (average mu = 0.885, current mu = 0.833) allocation failure
Jun 23 11:50:09 PM  [68:0x547f6d0]   378191 ms: Mark-sweep (reduce) 257.7 (264.5) -> 252.5 (264.0) MB, 778.1 / 0.1 ms  (+ 1.6 ms in 3 steps since start of marking, biggest step 0.6 ms, walltime since start of marking 783 ms) (average mu = 0.805, current mu = 0.566) allocatio
Jun 23 11:50:09 PM  
Jun 23 11:50:09 PM  <--- JS stacktrace --->
Jun 23 11:50:09 PM  
Jun 23 11:50:09 PM  FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
Jun 23 11:50:09 PM   1: 0xa222f0 node::Abort() [node]
Jun 23 11:50:09 PM   2: 0x96411f node::FatalError(char const*, char const*) [node]
Jun 23 11:50:09 PM   3: 0xb97f1e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
Jun 23 11:50:09 PM   4: 0xb98297 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
Jun 23 11:50:09 PM   5: 0xd52fd5  [node]
Jun 23 11:50:09 PM   6: 0xd83bbe v8::internal::EvacuateNewSpaceVisitor::Visit(v8::internal::HeapObject, int) [node]
Jun 23 11:50:09 PM   7: 0xd8fbf6 v8::internal::FullEvacuator::RawEvacuatePage(v8::internal::MemoryChunk*, long*) [node]
Jun 23 11:50:09 PM   8: 0xd7bd8f v8::internal::Evacuator::EvacuatePage(v8::internal::MemoryChunk*) [node]
Jun 23 11:50:09 PM   9: 0xd7c008 v8::internal::PageEvacuationTask::RunInParallel(v8::internal::ItemParallelJob::Task::Runner) [node]
Jun 23 11:50:09 PM  10: 0xd6e8e9 v8::internal::ItemParallelJob::Run() [node]
Jun 23 11:50:09 PM  11: 0xd91b50 void v8::internal::MarkCompactCollectorBase::CreateAndExecuteEvacuationTasks<v8::internal::FullEvacuator, v8::internal::MarkCompactCollector>(v8::internal::MarkCompactCollector*, v8::internal::ItemParallelJob*, v8::internal::MigrationObserver*, long) [node]
Jun 23 11:50:09 PM  12: 0xd923ec v8::internal::MarkCompactCollector::EvacuatePagesInParallel() [node]
Jun 23 11:50:09 PM  13: 0xd925b5 v8::internal::MarkCompactCollector::Evacuate() [node]
Jun 23 11:50:09 PM  14: 0xda45b1 v8::internal::MarkCompactCollector::CollectGarbage() [node]
Jun 23 11:50:09 PM  15: 0xd60878 v8::internal::Heap::MarkCompact() [node]
Jun 23 11:50:09 PM  16: 0xd62368 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
Jun 23 11:50:09 PM  17: 0xd657ac v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
Jun 23 11:50:09 PM  18: 0xd33e5b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
Jun 23 11:50:09 PM  19: 0x107c5af v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
Jun 23 11:50:09 PM  20: 0x1423279  [node]
Jun 23 11:50:09 PM  'next dev' failed with status code: null
Jun 23 11:50:13 PM  ==> Starting service with 'blitz start'

I’ve never had this before and didn’t encounter it when running the website locally. Does anyone know why this happening / how it can be fixed? Appreciate any help I can get!

Hi @dimitriborgers,

Render services on the Starter plan are limited to 512mb of RAM. If your application uses more than that the service will be killed and restarted which won’t happen when running locally. It is difficult to say what specifically in your app is causing the memory spike, but you could try to add some logging to see if there are any memory leaks. If you notice this happening frequently I would recommend upgrading the plan to Starter Plus which offers 1gb of RAM.

Hi @tyler, this is super helpful, thank you! This is a very open question, but what usually takes up RAM? Does the length of the HTML file or size of the Javascript bundle affect use of RAM? Does outputting things with console.log() increase RAM? What is the RAM even used for?

Asking these because I’m a noob and also I’ve noticed that opening more pages of my website will increase the RAM usage, but when I close them, the RAM usage stays high (according to the metrics dashboard). The metrics show that my app is also using 396MB when no one is on the website (it’s just idle), which seems astronomically high.

Whenever a Node.js service is running it will use RAM to perform the operations coded in the application just like a program running on your computer. There are many reasons an application can use a lot of RAM but with Node.js applications running in a memory restricted environment i.e. < 1GB it often results from the built in garbage collector not being called. As a default, a Node.js process will try to use about 1.5GBs of memory before calling the garbage collector. Here is an article that outlines more of how this works Hunting a Ghost - Finding a Memory Leak in Node.js | @RisingStack.

1 Like

Thank you! This was very helpful, very much appreciate the help.

Does starter plus still offer the 1GB of RAM mentioned in an earlier comment? Reading the website today it seems to be still 512MB RAM but just more CPU

The Starter Plus instance type is no longer available.

Alan

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