allocation
Reserving memory for a new object on the heap.
In more detail
Each allocation must later be reclaimed by the garbage collector, so needless allocations in hot code cost time. Boxing, string concatenation in loops and Task objects are common sources.
Related terms
- heap — The area of memory where a program stores objects whose size or lifetime is not known in advance, typically reclaimed by a garbage collector.
- garbage collection — The automatic freeing of memory held by objects that the program can no longer reach.
- boxing — Wrapping a value type such as an int in an object on the heap so it can be treated as an object.
- hot path — Code that runs very often, such as on every request, where small costs add up.
Taught in
- The C# Language: Types, Variables, and Flow Control — Modern .NET Core, C# & Enterprise Microservices
- Collections, Generics, and LINQ — Modern .NET Core, C# & Enterprise Microservices
- Async and Await: Managing Concurrency — Modern .NET Core, C# & Enterprise Microservices