Staying friendly with the GC
summary
Practical claims and concrete numbers decide: .Net GC pauses consume up to 63% GC time in an unoptimized import, optimizations using BenchmarkDotNet measurements plus stackalloc and fixed pointers and custom allocators drop GC wait to zero and make a million-document import about 3x faster. Examples include arena and buddy allocators, pooling, unsafe pointers, unmanaged memory with fencing and ref counting, and a RavenDB/Sparrow-style implementation that replaces hot-path heap allocations with deterministic or pooled memory.
AI-written summary · about
chapters (23)
- 0:00Start
- 1:40Garbage Collector: Developer's best friend
- 2:34Garbage Collector: Developer's worst enemy
- 4:25Logical representation of the managed heap
- 6:45GC collection rules
- 7:22Trivial Optimizations
- 9:54Q3 shades of memory in .Net
- 13:04Stack memory - find most frequent status
- 19:28Reverse String 3
- 22:49Unmanaged Heap - Reverse String
- 24:33MEMORY ALLOCATORS
- 25:55Memory Allocator Monotonic
- 29:01Memory Allocator - Multipool (Buddy System)
- 32:11Memory Allocator Considerations
- 33:30There is no silver bullet....
- 34:29The test
- 35:12Performance results
- 36:28Increased complexity → More issues
- 36:53Buffer overlaps - Electric Fence
- 38:42Memory Leaks - Reference Counting
- 40:11Memory Leaks/Usage after release - Finalizer
- 40:57The moral of the story
- 42:55Questions?
related talks
58mLook Mommy, No GC!
43mThe .NET Garbage Collector
06mInterview
42mMeasure Twice, Optimize Once: Real-World .NET Profiling with Visual Studio
52mGC Tuning & Troubleshooting Crash Course
01h 00mWriting Allocation Free Code in C#
39mMemory Efficient Java
01h 02mPerformance tricks I learned from contributing to the Azure .NET SDK
