High memory usage after upgrading Azure Function containers to .NET 8

ramprasad.r 85 Reputation points
2025-12-22T06:44:46.2066667+00:00

We upgraded our Azure Function services to .NET 8 and run them as custom containers on AKS.

After the upgrade, we observe that all Function containers consistently use ~75–90% of the configured memory limit (2 Gi). Memory usage increases gradually after pod startup and stabilizes, while CPU usage remains low and there are no OOMKills or restarts.

This behavior was not observed prior to the .NET 8 upgrade and is now visible after pod restarts and improved monitoring.

We have investigated and observed:

  • Memory resets after pod restart and grows again (no cross-pod leak)
  • Similar memory usage across multiple Function services
  • Stable CPU usage
  • No continuous unbounded memory growth

We would like Microsoft to:

  1. Confirm whether this memory behavior is expected for Azure Functions on .NET 8 in containerized environments
  2. Provide official guidance or documentation on recommended memory sizing for .NET 8 Azure Function containers
  3. Confirm whether any tuning or configuration is recommended to reduce baseline memory usage

This information is required for capacity planning and PROD rollout assurance.

User's image

Azure Kubernetes Service
Azure Kubernetes Service
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vinodh247 40,296 Reputation points MVP Volunteer Moderator
    2025-12-22T09:52:57.0033333+00:00

    Hi ,

     

    Thanks for reaching out to Microsoft Q&A.

     Yes, what you are seeing is expected behaviour with .NET 8 in containerised azure functions, especially on AKS.

    .NET 8 has a more aggressive GC and memory reservation strategy compared to earlier runtimes. The runtime proactively reserves heap memory up to a percentage of the container limit to reduce allocation pressure and GC pauses. As a result, memory usage ramps up after startup and then stabilises, even when CPU is low and there is no leak. This is by design and commonly shows as 70–90 percent of the limit in steady state.

    There is no MS guidance today that gives a precise “baseline memory” number for .NET 8 Functions containers. The practical recommendation is to size memory based on steady-state usage, not idle usage, and treat the reserved memory as committed capacity. For 2 Gi limits, what you see is normal.

    Tuning options are limited. You can experiment with DOTNET_GCHeapHardLimit or DOTNET_GCHeapHardLimitPercent, but Microsoft does not officially recommend overriding GC limits for Azure Functions unless you deeply understand the workload, as it can hurt throughput and latency. There is no supported setting to bring memory back to .NET 6 levels.


    Bottom line: this is not a leak, not a regression bug, and not an AKS issue. Plan capacity assuming higher baseline memory for .NET 8 Functions, validate under peak load, and proceed to PROD with adjusted limits rather than chasing the usage down.

    Please 'Upvote'(Thumbs-up) and 'Accept' as answer if the reply was helpful. This will be benefitting other community members who face the same issue.


Your answer

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