Index · Common pitfalls
1 min readRapid overview
Common pitfalls
| Bad Practice | Why it’s bad | Fix |
|---|---|---|
Using new objects inside tight loops | Floods Gen 0 | Reuse pooled objects |
string.Concat or + in loops | Creates new string every time | Use StringBuilder or spans |
| LINQ in hot paths | Allocates enumerators, closures | Use for loops |
| Boxing value types | Allocates on heap | Use generics / avoid casting to object |
| Repeatedly allocating buffers | LOH churn | Use ArrayPool<T> |
| Returning large arrays | LOH growth | Reuse pooled arrays or slice spans |