D Ranges in C#

David Piepgrass qwertie256 at gmail.com
Sat Jun 1 11:58:07 PDT 2013


>> You shouldn't be using 32-bit indices on x64, that defeats the 
>> whole
>> point of x64.
>
> As of .NET 4.5, 64bit array indexes are supported as well.
>
> http://msdn.microsoft.com/en-us/library/hh285054.aspx

Don't forget that we're talking about a *hashtable* here. If a 
.NET hashtable used 64-bit indexes (or pointers) it would require 
8-12 bytes more memory per entry, specifically 32 bytes total, 
including overhead, if the key and value are 4 bytes each.

An in-memory hashtable that requires 64-bit indexes rather than 
32 bits would have to contain over 4 billion entries which would 
take at least 128 GB of RAM, assuming 8 bytes for each key-value 
pair!!! In fact it's worse than that, as the dictionary grows by 
size-doubling and contains a certain amount of unused entries at 
the end.

No thanks, I'd rather save those 8 bytes and accept the 4 billion 
limit, if you don't mind.


More information about the Digitalmars-d mailing list