What is the maximum data limit on a <string> in C #?

How many values ​​can I add to the list?

For example:

List<string> Item = runtime data 

Data is not fixed in size. It may be 10,000 or more than 1,000,000. I have Googled, but have not found the exact answer.

+45
c #
Oct 11 2018-10-10
source share
3 answers

The maximum number of elements that can be stored in the current implementation of List<T> , theoretically, Int32.MaxValue is just over 2 billion.

In the current Microsoft CLR implementation, there is a limit on the maximum object size of 2 GB. (It is possible that other implementations, such as Mono, do not have this limitation.)

Your specific list contains strings that are reference types. The link size will be 4 or 8 bytes, depending on whether you work on a 32-bit or 64-bit system. This means that the practical limit on the number of lines you can save is approximately 536 million on 32-bit or 268 million on 64-bit versions.

In practice, you will most likely run out of allocated memory before you reach these limits, especially if you are running a 32-bit system.

+64
Oct 11 2018-10-11
source share

2147483647, because all the functions in the list are used with int.

Source from mscorlib:

 private T[] _items; private int _size; public T this[int index] { get { //... } } 
+8
Oct 11 2018-10-10
source share

list.Count () is int32, so it should be the maximum limit for int32, but how your list works on this limit is a wonderful observation.

if you perform some manupulation operations on a list, this will theoretically be linear.

I would say that if you have a very large number of thnink elements about concurrent collections in .net 4.0, this will make your list operations more responsive.

+3
Oct 11 2018-10-10
source share



All Articles