<story><title>Allocation is cheap in .NET until it is not</title><url>http://tooslowexception.com/allocation-is-cheap-until-it-is-not/</url></story><parent_chain><item><author>narag</author><text>This brought memories of that pattern (flyweight?) where the data was stored outside the objects, possibly in an array. An object was instantiated only to hold an index to the array position and allow access. That&amp;#x27;s dirty cheap!</text></item></parent_chain><comment><author>manigandham</author><text>It&amp;#x27;s still commonly used. The NFX library has Pile which does this well for holding large data:&lt;p&gt;&lt;a href=&quot;http:&amp;#x2F;&amp;#x2F;nfxlib.com&amp;#x2F;book&amp;#x2F;caching&amp;#x2F;pile.html&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;nfxlib.com&amp;#x2F;book&amp;#x2F;caching&amp;#x2F;pile.html&lt;/a&gt;&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.infoq.com&amp;#x2F;articles&amp;#x2F;Big-Memory-Part-1&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.infoq.com&amp;#x2F;articles&amp;#x2F;Big-Memory-Part-1&lt;/a&gt;</text></comment>
<story><title>Allocation is cheap in .NET until it is not</title><url>http://tooslowexception.com/allocation-is-cheap-until-it-is-not/</url></story><parent_chain><item><author>narag</author><text>This brought memories of that pattern (flyweight?) where the data was stored outside the objects, possibly in an array. An object was instantiated only to hold an index to the array position and allow access. That&amp;#x27;s dirty cheap!</text></item></parent_chain><comment><author>pjmlp</author><text>That pattern can be done in .NET via native memory allocation (MarshalInterop and SafeHandles).&lt;p&gt;With the latest C# 7.x features will become easier to use it.</text></comment>