How to fix OutOfMemoryException thrown on Azure AKS?

Rehaan 26 Reputation points
2023-02-07T08:00:58.0033333+00:00

Hi

I have deployed a application pod in Azure AKS which accepts a parameter of type byte array. I am sending a file byte array of 120 MB but it throws OutOfMemoryException.

Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HMO8F59CUA9H", Request id "0HMO8F59CUA9H:00000002": An unhandled exception was thrown by the application.
      System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
         at System.GC.AllocateNewArray(IntPtr typeHandle, Int32 length, GC_ALLOC_FLAGS flags)

My node pool has 16 GB RAM.

Container config:

resources:  requests:    memory: "200Mi"    cpu: "100m"  limits:    memory: "200Mi"    cpu: "100m"
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,854 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AirGordon 7,105 Reputation points
    2023-11-07T07:54:04.4+00:00

    I'd suggest you start by significantly bumping the request for memory and removing the limit from the pod in your dev environment. This will allow your code to run, and for you to better troubleshoot without adding the Kubernetes complexities. Limits for memory tell Kubernetes to kill the pod if it reaches that value.

    After you have your code working properly, put your resource limit back.

    0 comments No comments