runtime icon indicating copy to clipboard operation
runtime copied to clipboard

"unmanaged memory" issue with dotnet 6

Open bhosale-ajay opened this issue 4 years ago • 10 comments

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

dotnet 5 memory consumption

Screenshot for dotnet 6

dotnet 6 memory consumption

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

  1. How to probe unmanaged memory and pinpoint issues?
  2. Any useful commands for WinDbg/dotnet-dump to analyze "unmanaged memory"
  3. 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.

bhosale-ajay avatar Nov 01 '22 15:11 bhosale-ajay

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.

ghost avatar Nov 01 '22 15:11 ghost

Can you run it on Windows ? If positive, .NET Memory Profiler might help with native memory leaks.

NN--- avatar Nov 01 '22 22:11 NN---

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?

bhosale-ajay avatar Nov 01 '22 23:11 bhosale-ajay

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.

NN--- avatar Nov 01 '22 23:11 NN---

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

dotnet 5 memory consumption

Screenshot for dotnet 6

dotnet 6 memory consumption

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

  1. How to probe unmanaged memory and pinpoint issues?
  2. Any useful commands for WinDbg/dotnet-dump to analyze "unmanaged memory"
  3. 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:

area-GC-coreclr, untriaged

Milestone: -

ghost avatar Nov 02 '22 08:11 ghost

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.

Maoni0 avatar Nov 02 '22 09:11 Maoni0

@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

bhosale-ajay avatar Nov 02 '22 13:11 bhosale-ajay

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?

BagJo avatar Nov 05 '22 09:11 BagJo

have you tried valgrind as I mentioned above?

Maoni0 avatar Nov 07 '22 22:11 Maoni0

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.

bhosale-ajay avatar Nov 09 '22 13:11 bhosale-ajay