Search code examples
linuxasp.net-coreubuntuasp.net-web-apimemory

ASP.NET API consumes more memory on Ubuntu


I have an ASP.NET Core API app that I need to publish on my production server which is run on Ubuntu. When publish the app and run it on MS Windows it takes a reasonable amount of memory.

enter image description here

When I move the app to my production server htop shows that it takes a significant amount of memory compared to Windows.

enter image description here

So why is this happening? Another question as well: Why is there more than one OS process running the same app?


Solution

  • The issue was with the version of the .NET I was using: .NET 7.0. See Huge memory usage regression in dotnet 7 on linux Github issue.

    For the OS processes running the same app:

    Threads: Implemented by the kernel as processes. That is, there are no dedicated data structures representing threads. Rather, a thread is a process that shares certain resources (such as memory or signal handlers) with other processes. The kernel identifies a thread via thread IDs (TID) and thread group IDs (TGID), with the semantics that a shared TGID value means a multithreaded process (in user land; there are also kernel threads, but that’s beyond our scope). [Hausenblas, Michael. Learning Modern Linux. Ch. 02.]