I have a .NET 6 WebAPI running as a Docker container. Recently, I’ve encountered an issue where the memory usage of this container continuously increases over time as it serves HTTP requests. Currently, the container’s memory usage has reached 6GB. This API service primarily performs CRUD operations using EF Core.
Today, I tried running dotnet-dump collect -p <p_id> inside the container to collect a dump file. Surprisingly, the total size reported by dumpheap -stat is only around 300MB, which is significantly smaller compared to the 6GB memory usage reported by Docker (via docker stats). Below is the output of dumpheap -stat:
This is the output of docker stats command:
I checked /proc//smaps for any clues. What I found is that the report indicates a large amount of Anonymous Memory with significant sizes. Below is an example:
I would appreciate any suggestions or insights to help me determine what is consuming the memory.
4