• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

1.4K
Views
ASP.NET core linux(centos) docker container, what is the mechanism of Garbage Collection?

I have tried to deploy my ASP.NET Core API as a linux docker container on a EC2 CentOS server. Now I'm facing with memory leak issue because my application eating a lot of RAM.

The problem is that when I try to test my API with a number of concurrent requests so my API's RAM usage increase as linear line, but after some period of time it's still grow and not released (seem like the garbage collection is not working).

My API is just simple CRUD API and it only depends on EF core and RabbitMQ client.

When I run the docker image without the memory limit then the RAM usage keep increasing when ever the request come.

MEM USAGE / LIMIT --------- MEM %
890,93 MB/ 15.21 GB --------- 5.xx%

But if I set the Memory limit to 300MB then the ram usage increase to arround 270MB and it reduces to 150MB.

This make me a bit confuse, Is that MEM limit trigger the Garbage Collection to run when RAM usage meet the limit size? Will I also need to set the MEM limit in production ENV?

Here is my DockerFile

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY "MyAPI.csproj" ./
RUN dotnet restore "MyAPI.csproj"
COPY . .
WORKDIR "/src"
RUN dotnet build "MyAPI.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "MyAPI.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "MyAPI.dll"]
over 3 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error