🎯 Lab Objective
By the end of this lab, you will be able to:
✔ Launch and use Resource Monitor
✔ Analyze CPU, Memory, Disk, and Network usage for a .NET application
✔ Identify performance bottlenecks
✔ Detect high CPU, memory leaks, disk thrashing, and network issues
✔ Use Resource Monitor to troubleshoot real-time .NET app problems
This lab is hands-on, and every step includes expected results + observations.
————————————
🧪 LAB 0 — Prerequisites
————————————
Before starting:
✔ Windows 10/11 or Windows Server
✔ .NET 6 or .NET 7 runtime installed
✔ A sample .NET app (API, console, or background worker)
If you don’t have one, you can create a quick sample API:
dotnet new webapi -n DemoApi
cd DemoApi
dotnet run
Code language: JavaScript (javascript)
This will run on:
http://localhost:5000 or http://localhost:5241 (depending on your version)
————————————
🧪 LAB 1 — Launch Resource Monitor
————————————
Step 1: Open ResMon
Press:
Win + R → resmon
OR
Ctrl + Shift + Esc → Task Manager → Performance → Open Resource Monitor
Expected Output
You see an interface with tabs:
- Overview
- CPU
- Memory
- Disk
- Network
————————————
🧪 LAB 2 — Monitor CPU Usage of .NET App
————————————
Step 1: Run your .NET application
Example:
dotnet run
Step 2: Open Resource Monitor → CPU Tab
Step 3: Filter by the .NET process
Look for:
- dotnet.exe
- w3wp.exe (if IIS hosted)
- yourapp.exe (self-contained builds)
Check these fields:
- Image
- PID
- Threads
- CPU %
- Average CPU
Step 4: Simulate load
Use a separate terminal:
for /l %i in (1,1,1000) do curl http://localhost:5000/weatherforecast
Code language: JavaScript (javascript)
Or use Postman runner.
Observe:
- CPU usage rises
- Thread count increases
- Your .NET process moves to the top of the CPU list
Step 5: Analyze Wait Chain for Deadlocks
Right-click your .NET process →
Analyze Wait Chain
Expected Result
- No wait chain = no deadlock
- If threads wait for each other → potential deadlock
————————————
🧪 LAB 3 — Memory Analysis for .NET App
————————————
Step 1: Open Memory tab
Filter your .NET process.
Look at:
- Commit (KB)
- Working Set (KB)
- Private (KB)
- Shareable
- Hard Faults/sec
Step 2: Trigger .NET memory usage
Modify API or run a loop:
var data = new List<byte[]>();
for(int i=0; i<50000; i++)
{
data.Add(new byte[1024 * 50]); // 50 KB
}
Code language: PHP (php)
Run load test again.
Expected Observations
- Working Set increases
- Commit size increases
- Hard Faults/sec spikes if system memory is low
Step 3: Identify memory leak behavior
If Working Set grows continuously without dropping → possible memory leak.
————————————
🧪 LAB 4 — Disk I/O Analysis for .NET
————————————
This is crucial for:
- Logging-heavy applications
- APIs that write large files
- Upload/download endpoints
- Apps with heavy DB operations
Step 1: Open Disk tab
Filter by your dotnet.exe process.
Observe:
- Read (B/sec)
- Write (B/sec)
- Total (B/sec)
- Disk Queue Length
- Response Time
- File path being accessed
Step 2: Simulate Disk Load
Create a .NET endpoint that writes files:
[HttpGet("write")]
public IActionResult WriteDemo()
{
System.IO.File.WriteAllText("test_" + Guid.NewGuid() + ".txt", new string('A', 1000000));
return Ok();
}
Code language: PHP (php)
Call it multiple times:
for /l %i in (1,1,200) do curl http://localhost:5000/write
Code language: JavaScript (javascript)
Expected Observations
- Disk write activity spikes
- Resource Monitor shows file names like:
C:\path\yourapp\test_*.txt - Disk Queue Length increases
- Response Time shows milliseconds → indicates I/O latency
Interpretation
- High queue length → Disk bottleneck
- High response time → slow disk (SSD/HDD issue)
- Heavy writes → Logging too much
————————————
🧪 LAB 5 — Network Analysis for .NET
————————————
Step 1: Go to Network Tab
Filter by your .NET process.
Observe:
- Send (B/sec)
- Receive (B/sec)
- Total bytes/sec
- Remote Address
- Port
- TCP connections
- Failures
Step 2: Simulate High Network Load
Run:
for /l %i in (1,1,300) do curl http://localhost:5000/weatherforecast
Code language: JavaScript (javascript)
Or:
Use Postman runner (10–100 requests/sec).
Expected Observations
- Network usage increases
- You can see your API responding on port:
- 5000
- 5241
- custom hosted port
- TCP connections show:
- Local Address
- Remote Address
- State (Established)
Advanced Scenario
If your .NET app calls external APIs, you can see:
- Outgoing IP
- Latency issues
- Failed connections
————————————
🧪 LAB 6 — Isolate and Focus on a Single Process
————————————
Resource Monitor allows FILTERING by process.
Step 1: Check the box next to dotnet.exe
Now the entire UI filters:
✔ CPU → Only your threads
✔ Disk → Only your files
✔ Network → Only your connections
✔ Memory → Only your segments
This is the most powerful feature in Resource Monitor.
————————————
🧪 LAB 7 — Detect Thread Starvation / Deadlocks
————————————
Step 1: CPU Tab → Expand Threads
Look for:
- A single thread using high CPU
- Many threads blocked
Step 2: Right-click → Analyze Wait Chain
Expected
- App may show:
“One or more threads are waiting on each other” → Deadlock
This helps catch:
- async/await deadlocks
- database blocking
- file I/O blocking
- network blocking
————————————
🧪 LAB 8 — Performance Optimization Decision Points
————————————
Using Resource Monitor, collect findings:
1. CPU Bottleneck → Optimize
- Reduce JSON serialization
- Optimize LINQ projections
- Use async I/O
- Reduce heavy loops
- Add caching
2. Memory Bottleneck → Optimize
- Fix memory leaks
- Reduce LOH allocations
- Use pooling
- Dispose unmanaged resources
3. Disk Bottleneck → Optimize
- Reduce logging
- Use async disk I/O
- Move logs to separate drive
- Optimize temp-file usage
4. Network Bottleneck → Optimize
- Add connection pooling
- Reduce large payloads
- Enable compression
- Optimize external API calls
————————————
🧪 LAB 9 — Final Validation
————————————
After optimization:
Re-run load
- Use curl/Postman
- Generate real load
Re-check Resource Monitor
- CPU should stabilize
- Disk writes reduced
- Hard faults minimized
- Network calls optimized
- Memory usage flattened
————————————
LAB END: Summary
————————————
After completing this lab, you can:
✔ Use Resource Monitor to analyze:
- CPU
- Memory
- Disk
- Network
✔ Filter by .NET process
✔ Identify bottlenecks
✔ Detect deadlocks, file locks, port usage
✔ Optimize .NET application performance using real-time signals
Resource Monitor is a real-time diagnostic powerhouse for Windows and crucial for effective .NET performance optimization.
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