简体   繁体   中英

Does .NET provide a way to set 64-bit capacities for collections?

I'm using some very large collections (lists and dictionaries), containing more than Int32.MaxValue items.
The machines running my application may have anywhere from 64 - 1024 GB of RAM, so memory space is not a concern at the moment.

I need to know two things:

a) Can the System.Collections.Generic objects handle 64-bit item counts?

b) If so, is there a way to set the initial capacity to a value greater than Int32.MaxValue ?

I've been reading about the significant performance benefits that come with setting the initial capacity exactly where you need it - eg here .
I imagine the importance of setting the initial capacity only becomes more and more significant as collections get larger and larger.

According to the MSDN docs on Lists and HashSets , you can set the maximum capacity to 2 billion on 64 bit machines.

For very large List objects, you can increase the maximum capacity to 2 billion elements on a 64-bit system by setting the enabled attribute of the configuration element to true in the run-time environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM