Memory Performance Optimizations
In this module, we'll cover several memory performance optimizations for C# code.
Lesson Preview
We introduce a memory performance optimization for generation 0: allocate, use, and discard objects as quickly as possible so they die in generation 0 rather than migrate to generation 1 or 2. The lesson covers reducing unnecessary object creation and scoping references tightly so objects are automatically de-referenced when no longer needed.
Lessons
- Optimize GC for Gen:0 Preview 7 min
- Avoid the Event Handler Memory Leak 5 min
- Example: String Allocations in Gen:0 5 min
- Demo: Tracking Gen:0 Allocations 9 min
- Demo: Optimizing Gen:0 Allocations 6 min
- Optimizing for Object Lifetime 2 min
- Make Large Objects Long-Lived 6 min
- Demo: Object Pooling (part 1) 5 min
- Demo: Object Pooling (part 2) 3 min
- Make Small Objects Short-Lived 10 min
- Make Short-Lived Objects Small 9 min
- Make Long-Lived Objects Large 4 min
- Object Lifetime Recap 6 min
- Structs versus Classes 9 min
- Demo: Benchmarking Structs versus Classes 4 min