In this tutorial, we will learn how to use timeline profiling to detect excessive GCs and their causes.
Step 1. Running the Profiler and Getting a Snapshot
Step 2. Starting Analysis
Step 3a. Where Does Memory Traffic Come From? Analyzing Garbage Collections
Step 3b. Where Does Memory Traffic Come From? Analyzing Memory Allocations
Step 4. Improving the Code
Step 5. Verifying the Fix
- Rebuild the solution and perform profiling one more time as described in Step 1.
- After the snapshot is open in Timeline Viewer, switch Analysis Subject to Memory Allocation.
- Look at the Threads diagram. Our improvement works! Memory traffic was reduced from 6 GB to 164 MB in FileProc.
If you zoom into the time interval where FileProc processed files, you’ll see that file processing has sped up significantly. Now, it takes only 370 ms to process all files, compared to 3445 ms before the fix.