[...]
The size limit imposed on an object, or more specifically an array is
2GB (Contiguous Bytes!), is not in the type system, it's purely
artificial. There is no such thing like a "variable" that restricts the
size of an array (or an object in general) to 2^31 or 2^32.
Of course there is.
The Array's RTT "length" field is 32 bit or 64 bit(there is even the
GetLongLenth method and LongLength property), depending on the CLR (and
JIT).
Array.Length is _defined_ in the .NET API as being a 32-bit value.
Even if you count the LongLength property, it's not true 64-bit support
since it will never return a value that actually requires the 64-bit
width of the value.
This is the sort of thing that I mean when I say that .NET doesn't
support 64-bit code. Array.LongLength is about as close 64-bit support
as .NET comes, and frankly even there it fails since the property never
actually can take advantage of more than 32 bits. The rest of .NET
doesn't even provide the illusion of having a 64-bit API. It's very
tightly tied to the 32-bit world.
Note also, that this field denotes the number of *elements* in the array,
Yes, I know. So what? My point is that there's more to being 64-bit
than just the pointer size, or for that matter the size of the object
being stored. In fact, that's what I wrote already.
The difference between Win16 and Win32 is much more than just the size
of a pointer. The same thing applies here.
so, even on 32-bit, an array could possibly hold 2^32 * 8 (long[],
double[]) 32GBytes and even more for an array of reference types like
strings for instance.
So what? You still can't have an array longer than a length defined by
32 bits.
However, the CLR team decided to restrict the *memory* allocated by a
single object on the GC heap to 2GB, this restriction doesn't mean that
your application is not a true 64-bit application.
That's only true if you use a very narrow definition of "true 64-bit
application". I don't happen to agree with your definition, nor is
your definition consistent with the use of "N-bit" to describe APIs
throughout the history of Windows (and before, for that matter).
Note that native frameworks and class libraries impose the same
restrictions on the size their containers, do you think that there is
no restriction for the size of a std::vector?
Why would you think that I do? Looks like you're going off on a tangent here.
well, std::vector (from the MS CRT) has a "max_length" field of
32-bit, this for 32 and 64 bit, does that mean that your 64-bit
compiled C++ applications aren't true 64-bit?.
Who cares? This isn't about whether the "compiled application" is a
"true 64-bit" application. This is about the API that .NET exposes.
And for sure, your std::vector example is an example of an API that IS
NOT 64-bit.
Similar restrictions are baked in the 64-bit OS, a lot of data
structures are limited to 2^32 or less, do you believe you can "malloc
" or "VirtualAlloc" 64^2 memory on 64 bit Windows (you can't allocate
true 64 bit OS?
No, of course not. It's not even a decent straw man you're showing me here.
In a 64-bit API, the API allows the code to at least attempt to
allocate a full 2^64. The fact that you'll never succeed is
immaterial, just as the fact that you'd never succeed to allocate a
full 2^32 in Win32 was immaterial. The API itself supported a full 32
bits in the allocation methods, and a 64-bit API need only support a
full 64 bits in the allocation methods, whether or not one can actually
allocate an object that big.
You are getting confused between the API and the underlying mechanics.
You might as well say that whether an application is 64-bit, 32-bit, or
something even less (16-bit? 8-bit) depends on how much space is left
in the processes virtual address space. That would be just as silly as
what you're asserting above.
Sure you can, what stops you?
The fact that nothing about .NET actually supports true 64-bit code.
Just because you can compile 32-bit application written to a 32-bit API
as a 64-bit executable doesn't make the API a 64-bit API, no matter how
wishfully you think it will.
Pete