"unmanaged memory" issue with dotnet 6
After porting from dotnet 5 to dotnet 6 a backend application is consuming a lots of "unmanaged memory". It is a complex F# application hosted on Linux, runs multiple process, lots of serialization of messages from EventStore and have actor model implemented with AKKA.NET.
No major code changes during port.
Screenshot for dotnet 5
Screenshot for dotnet 6
The unmanaged memory can peak to 6 GB, and if process remains idle (no messages in EventStore) it releases some unmanaged memory and settles around 3-4 GB.
Other Details
- OS : Linux (Ubuntu 22.04, Debian 10.11)
- dotnet 6 Version : 6.0.401
- dotnet 5 Version : 5.0.408
Used dotnet-dump and also dotMemeory from JetBrains. (dotMemory does not provide any insights into "unmanaged memory"). Currently exploring WinDbg and dotnet-dump commands.
Help I am looking for is
- How to probe unmanaged memory and pinpoint issues?
- Any useful commands for WinDbg/dotnet-dump to analyze "unmanaged memory"
- Possible reasons on why dotnet 6 needs so much unmanaged memory when dotnet 5 can do with a relatively low footprint.
If this is not a right forum, please guide and close the issue if required.
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
Can you run it on Windows ? If positive, .NET Memory Profiler might help with native memory leaks.
Not possible to run on Windows, the setup is mostly Linux based with lots of supporting systems. Does .NET Memory Profiler supports analyzing dumps collected on Linux?
Sorry, I don't have an answer for that. I haven't used it recently and needed only for Windows. Perhaps worth a try, it has a free trial.
Tagging subscribers to this area: @dotnet/gc See info in area-owners.md if you want to be subscribed.
Issue Details
After porting from dotnet 5 to dotnet 6 a backend application is consuming a lots of "unmanaged memory". It is a complex F# application hosted on Linux, runs multiple process, lots of serialization of messages from EventStore and have actor model implemented with AKKA.NET.
No major code changes during port.
Screenshot for dotnet 5
Screenshot for dotnet 6
The unmanaged memory can peak to 6 GB, and if process remains idle (no messages in EventStore) it releases some unmanaged memory and settles around 3-4 GB.
Other Details
- OS : Linux (Ubuntu 22.04, Debian 10.11)
- dotnet 6 Version : 6.0.401
- dotnet 5 Version : 5.0.408
Used dotnet-dump and also dotMemeory from JetBrains. (dotMemory does not provide any insights into "unmanaged memory"). Currently exploring WinDbg and dotnet-dump commands.
Help I am looking for is
- How to probe unmanaged memory and pinpoint issues?
- Any useful commands for WinDbg/dotnet-dump to analyze "unmanaged memory"
- Possible reasons on why dotnet 6 needs so much unmanaged memory when dotnet 5 can do with a relatively low footprint.
If this is not a right forum, please guide and close the issue if required.
| Author: | bhosale-ajay |
|---|---|
| Assignees: | - |
| Labels: |
|
| Milestone: | - |
have you tried valgrind I've only seen it used with c/c++ programs but since it's just counts when malloc/new are called without the corresponding free/delete, it seems like it should work on managed apps too if you care about finding native leaks.
@NN--- Thanks, .NET Memory Profiler could not load the dump created on Linux
@Maoni0 Thanks, Exploring it, massif is what my colleague planning to use
We are facing the same issue. Complex server application also with a lot of message serializing/deserializing running on dotnet 6.0.302 and ubuntu linux 20.04. The managed memory is pretty constant and the unmanaged memory rises to absurd levels. Is there a way to analyze where the unmanaged memory consumption originates from when running on linux?
have you tried valgrind as I mentioned above?
Thanks for following up, The issue was with Marten, The updated version (v3 -> v5) was creating types at Runtime and hence causing spike in unmanaged memory. Marten team explained the behavior here. Closing the issue now.

