Problem
When attaching dotMemory to a running .NET application running with Server GC mode, one might observer significant performance degradation.
Cause
This can happen for a variety of reasons:
- dotMemory switches the garbage collection mode after attaching if an application runs with Server GC. It switches GC mode because it’s not possible to collect the object graph using Server GC due to API limitations. As a result, the application may experience more frequent GC.
- dotMemory triggers a full garbage collection upon attaching and collecting a snapshot. This behavior is necessary to collect a full and accurate object retention graph. Full GC can take some time depending on memory state.
- Depending on the memory state and the environment, the snapshot collection can take from a few milliseconds to multiple seconds or more. During snapshot collection, all application threads will be paused.
Resolution
One can use a few different approaches to reduce the performance penalty or work around this issue:
- Unless you need full allocation data, using
dotmemory get-snapshotcommand is preferable if you want to collect a single snapshot in a high load or production environment. This way, dotMemory will collect necessary information and detach from the target process as soon as possible. - In case
dotmemory get-snapshotstill takes too long in a high-load environment, you can collect a dump without dotMemory (to avoid building an accurate object graph that can take some time) and importing via Import Process Dump. To collect a dump, you can:- use dotnet-dump (with default
Fulldump type) - or collect a standard Windows memory dump if the application is running on Windows
- use dotnet-dump (with default
Comments
0 comments
Please sign in to leave a comment.