FATAL ERROR: JavaScript heap out of memory only when deployed in Azure container apps

Amrish Syed Ahamed 0 Reputation points
2024-08-30T06:52:23.5466667+00:00

I have deployed the same (no code change) Node.js application in both Docker containers and Azure Container Apps. I've noticed a discrepancy in memory usage between the two environments.
In Azure Container Apps, the application's Memory Working Set Bytes continually increases, showing no fluctuations. Once it reaches 2GB, I encounter the following error: FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory. and once after restart it starts from 115 MB and works fine till it reaches 2 GB.

Conversely, in Docker containers, the Memory Working Set Bytes graph fluctuates, and I do not encounter this error.

I have attached a graph for reference: Capture4

I have got the v8.getHeapStatistics() for:

Docker container:
{ total_heap_size: 6582272, total_heap_size_executable: 524288, total_physical_size: 5941160, total_available_size: 4339910624, used_heap_size: 4768632, heap_size_limit: 4345298944, malloced_memory: 8192, peak_malloced_memory: 582752, does_zap_garbage: 0, number_of_native_contexts: 2, number_of_detached_contexts: 0 }

Azure container apps:
{ total_heap_size: 6053888, total_heap_size_executable: 524288, total_physical_size: 5531176, total_available_size: 4340732928, used_heap_size: 4294696, heap_size_limit: 4345298944, malloced_memory: 8192, peak_malloced_memory: 582752, does_zap_garbage: 0, number_of_native_contexts: 2, number_of_detached_contexts: 0 }

Can someone explain why this is happening and suggest possible solutions to address this issue?

Thank you in advance.

Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
399 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.