{"@attributes":{"version":"2.0"},"channel":{"title":"allocation on Olivier's Blog","link":"https:\/\/ogxd.github.io\/tags\/allocation\/","description":"Recent content in allocation on Olivier's Blog","generator":"Hugo -- gohugo.io","lastBuildDate":"Fri, 14 Mar 2025 13:12:00 +0200","item":{"title":"Optimizing C# collections with predictive sizing","link":"https:\/\/ogxd.github.io\/articles\/pre-allocated-collections\/","pubDate":"Fri, 14 Mar 2025 13:12:00 +0200","guid":"https:\/\/ogxd.github.io\/articles\/pre-allocated-collections\/","description":"Dynamic collections, such as the dynamic array (also known as a List in C#), are without a doubt one of the most common data structure, and not only in C# but in computer science in general.\nThe dotnet base class library exposes plenty of dynamic collections to fulfil a wide number of usecases: (System.Collections.)List&lt;T&gt;, Dictionary&lt;K, V&gt;, HashSet&lt;T&gt;, Queue&lt;T&gt;, Stack&lt;T&gt;, and more. But they all share one thing in common: they are based on dynamic reallocation of backing arrays, which can lead to suboptimal performance and excessive memory allocation."}}}