

A Complete Practical Guide for Memory Profiling Using Command Line
1. š What is dotMemory Console?
dotMemory Console (also called dotMemory Command-Line Profiler) is the free, headless version of JetBrains dotMemory that allows you to:
- Start .NET processes under memory profiling
- Attach to a running .NET process
- Automatically capture memory snapshots
- Trigger snapshots based on conditions (timer, memory growth, process start)
- Profile desktop apps, web apps, Windows services, IIS, WCF services
- Capture snapshots on servers, CI pipelines, or production-like environments
The console profiler produces snapshot (.dmw) files that can later be opened in the dotMemory GUI (paid), but everything up to taking snapshots is 100% free.
2. šÆ Why Use dotMemory Console?
Because GUI profilers cannot run in many real scenarios.
dotMemory Console is perfect for:
ā Profiling on servers
ā Profiling CI/CD pipelines
ā Profiling performance test environments
ā Profiling apps running under service accounts
ā Profiling IIS, Kestrel, Windows services
ā Capturing snapshots automatically during load tests
ā Capturing leaks in production-like staging
In short:
You use dotMemory Console when you need real-world profiling without installing heavy GUI tools.
3. š§ Why Memory Profiling Matters
Memory issues cause:
- High GC (Garbage Collection) ā CPU spikes
- Slow response times
- Server crashes
- Out-of-memory exceptions
- Leaks (objects never collected)
- Long-lived objects blocking GC
- LOH (Large Object Heap) fragmentation
dotMemory Console helps you capture snapshots at the EXACT moment the issue happens, which is not possible with GUI tools.
4. š§ Where dotMemory Console Can Be Used
| Environment | Supported? |
|---|---|
| Windows Desktop | ā |
| Windows Server | ā |
| Linux (.NET Core) | ā |
| macOS (.NET Core) | ā |
| Docker | ā |
| Remote servers | ā |
| CI pipelines | ā |
| IIS / IIS Express | ā |
| Windows Services | ā |
| Console apps | ā |
| ASP.NET Core apps (Kestrel) | ā |
| Worker Services | ā |
5. š How dotMemory Console Works (Internals)
- You start profiling using commands like:
dotMemory startdotMemory get-snapshot
- The profiler injects into the CLR runtime.
- It records allocation stacks, object references, and GC behavior.
- When a snapshot is triggered:
- It dumps the entire managed heap.
- It saves it into a
.dmwworkspace file.
- You later open
.dmwin GUI (optional) to see:- Objects
- Leaks
- GC roots
- Retained memory
- Allocation hot paths
6. š¦ Installation (FREE)
Option 1: Global Install (Recommended)
dotnet tool install --global JetBrains.dotMemory.Console
Code language: CSS (css)
Check version:
dotmemory --version
Option 2: Local Install (Project-based CI)
dotnet new tool-manifest
dotnet tool install JetBrains.dotMemory.Console
Code language: CSS (css)
Option 3: Manual Download ZIP
Download from JetBrains (no account needed):
Search āJetBrains dotMemory Console downloadā
Extract to:
C:\tools\dotmemory\
Run:
dotMemory.exe
Code language: CSS (css)
7. š§° Features of dotMemory Console (FREE)
ā Attach to running processes
ā Profile apps as they start
ā Support for .NET Framework and .NET Core
ā Automatic triggers
ā No GUI needed
ā Zero license cost
ā Works on servers
ā Snapshot packaging
ā Works with IIS / Kiestrel / Windows Services
ā Suitable for CI/CD
ā Very low overhead
8. ā” Advantages
| Advantage | Explanation |
|---|---|
| ā Free | The full command-line profiler is FREE |
| ā Works on Servers | No need to install big GUI tools |
| ā Automation | Perfect for CI, load tests |
| ā No IDE dependency | Works with any environment |
| ā Supports all .NET apps | Desktop, web, service |
| ā Trigger-based profiling | Catch leaks automatically |
| ā Lightweight | Low overhead vs GUI |
9. ā Limitations
| Limitation | Explanation |
|---|---|
| ā No visual interface | Must open snapshots in GUI (paid) |
| ā Cannot analyze snapshots in CLI | You only collect snapshots |
| ā No real-time object graph | GUI required to view |
| ā Not ideal for beginners | Requires understanding of profiling |
| ā Some runtime-specific features require GUI | E.g., graph-based navigation |
10. š How To Use dotMemory Console (Hands-On)
ā 10.1 Take Snapshot of Running Process
By process name:
dotMemory get-snapshot MyApp.exe --save-to-dir=C:\snaps
Code language: JavaScript (javascript)
By PID:
dotMemory get-snapshot 12564 --save-to-dir=C:\snaps
Code language: JavaScript (javascript)
dotMemory chooses highest-memory instance if multiple processes exist.
ā 10.2 Start App Under Profiling
dotMemory start --save-to-dir=C:\snaps C:\MyApp\MyApp.exe
While app runs, you can manually trigger snapshot:
get-snapshot
Code language: JavaScript (javascript)
OR:
Ctrl + Enter
ā 10.3 Start .NET Core App (Kestrel)
dotMemory start-net-core --save-to-dir=C:\snaps -- MyApp.dll
ā 10.4 Automatic Snapshots (Memory Increase Trigger)
Example: snapshot when memory increases by 40%
dotMemory start --trigger-mem-inc=40% --save-to-dir=C:\snaps MyApp.exe
Perfect for:
ā Memory leaks
ā Load-test environments
ā 10.5 Snapshots Every X Seconds
Every 30 seconds:
dotMemory start --trigger-timer=30s --save-to-dir=C:\snaps MyApp.exe
ā 10.6 At App Startup
dotMemory start --trigger-start --save-to-dir=C:\snaps MyApp.exe
ā 10.7 Profile IIS
Restart IIS under profiler:
dotMemory start-iis --save-to-dir=C:\snaps
Attach:
dotMemory get-snapshot w3wp --save-to-dir=C:\snaps
Code language: JavaScript (javascript)
ā 10.8 Profile Windows Service
Start profiling:
dotMemory start-windows-service MyServiceName --save-to-dir=C:\snaps
Take snapshot:
dotMemory get-snapshot MyServiceName --save-to-dir=C:\snaps
Code language: JavaScript (javascript)
ā 10.9 Profile Any Process Started Later
Use this for ācapture everything that starts nowā:
dotMemory profile-new-processes --save-to-dir=C:\snaps
Code language: JavaScript (javascript)
11. š What To See Inside Snapshots (When Opened in GUI)
Once you import .dmw file into dotMemory GUI, analyze:
- Overview Page
- Total objects
- Object count growth
- Retained memory
- Inspections
- Potential leaks
- Types that increase
- Long-lived objects
- Object Sets
- Group by type
- Size and count per type
- Retention Paths
- Why object is not collected
- GC roots
- Allocations
- Methods causing heavy memory traffic
- Compare Snapshots
- Before & after requests
- Leak tracking
12. š§Ŗ Real Use Cases
ā 12.1 Detect Memory Leak in ASP.NET Core Under Load
Run:
dotMemory start --trigger-mem-inc=20% --save-to-dir=C:\snaps -- dotnet MyApp.dll
Start JMeter / k6 load test
ā Snapshots collected ā Analyze retained size differences.
ā 12.2 Catch Leak in Windows Service
dotMemory get-snapshot MyServiceName --save-to-dir=C:\snaps
Code language: JavaScript (javascript)
Restart service ā reproduce issue ā compare snapshots.
ā 12.3 CI/CD Pipeline Memory Regression Check
In Jenkins/GitHub Actions:
dotMemory start-net-core --trigger-mem-inc=30% --save-to-dir=snaps -- MyApp.dll
Upload snaps to artifacts.
ā 12.4 Taking a Snapshot Right Before Crash
Use trigger:
dotMemory start --trigger-mem-inc=80% --save-to-dir=C:\snaps MyApp.exe
If memory shoots up (OOM), you get snapshot automatically.
ā 12.5 Auto Snapshots Every X Minutes During Long-Running Tests
dotMemory start --trigger-timer=120s --save-to-dir=C:\snaps MyApp.exe
13. š Snapshot Storage and Recovery
Save snapshots:
--save-to-dir=C:\snaps
If profiling crashed:
dotMemory recover C:\snaps
14. š§¾ Important Commands Cheat Sheet
| Purpose | Command |
|---|---|
| Start app under profiling | start |
| Start .NET Core app | start-net-core |
| Attach to process | get-snapshot <PID> |
| Auto snapshot on memory growth | --trigger-mem-inc=30% |
| Auto snapshot every X seconds | --trigger-timer=20s |
| Profile IIS | start-iis |
| Profile Windows Service | start-windows-service |
| Profile processes started later | profile-new-processes |
| Save snapshots | --save-to-dir=snaps |
| Recover workspace | recover |
15. šÆ Best Practices for Performance Engineers
ā Always save snapshots to a separate folder
ā Take a baseline snapshot
ā Take snapshot after load scenario
ā Always compare snapshots
ā Use memory-increase triggers for leaks
ā Do not profile production unless necessary
ā Automate snapshot collection in CI/CD
ā Keep snapshots small by recording at correct moments
ā Use GUI only for deep analysis
š FINAL SUMMARY
dotMemory Console = Free, powerful, server-ready memory profiler for .NET
It gives you:
- Automatic snapshots
- Profiling of server apps
- Integration with performance testing
- 100% automation via command line
- Ability to capture leaks exactly when they happen
- No need for GUI installation
To analyze snapshots ā you need dotMemory GUI (paid), but all profiling and snapshot generation is free.
Iām a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at Cotocus. I share tech blog at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow , and SEO strategies at Wizbrand.
Do you want to learn Quantum Computing?
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at WIZBRAND