Using C# (and Visual Studio 2010), I defined a struct of 5 bools (and nothing else). Then I created an array of 16515072 elements of that struct. Strangely, the ANTS Memory profiler shows that this array is occupying more than 80 MB of memory.
However, if the bits where perfectly packed it should only occupy ~10 MB. Even if the 5 bools were packed into (encoded by) a single byte (which I would expect), the array should only be ~16 MB.
How can I improve the packing of the array in order to reduce the memory it occypies? Are there any general best-pactices when optimizing the memory footprint of large arrays?
boolis taking a separate byte. There is no automatic packing optimization.booltakes one byte, so total memory is 5 * 16515072 B = 82575360 B = 82 MB