Memory Leak or Overconsumption in API Container Under Continuous Load

I’m currently running a .NET-based API inside a Docker container. During stress testing, I’ve observed that the container’s memory usage keeps increasing steadily when the API is hit continuously with requests — especially those that are resource-heavy (e.g., file decompression, zipping, memory-stream operations, etc.).
Despite:
Applying proper disposal patterns (using, Dispose, null)
Forcing GC.Collect() in finally blocks
Enabling GC tuning with these settings:
environment:

  • DOTNET_GCHeapHardLimitPercent=75
  • DOTNET_GCTrimCommitOnLowMemory=1
  • MALLOC_TRIM_THRESHOLD_=131072
  • DOTNET_GCHeapAffinitizeMask=0x3
  • DOTNET_DefaultStackSize=180000
    Periodically clearing cache in cronjobs
    Validating that no temp file or log buildup is occurring (du -sh)
    The container still keeps increasing memory usage until it crashes or gets OOM-killed. No memory is released back to the OS.

Can you share more details, like whether its about .net or .net core, and if its a Linux or Windows container?
Furthermore, the output of docker info is usually good to know, so we can see which exact docker version you are working with.

I am using dot net core and its linux container and docker info is
Version: 27.1.1
Context: desktop-linux
Debug Mode: false

Docker 27.1 is a year old. So I recommend to upgrade, so we don’t try to identify issues that might already have been fixed in the last 12 months.