Maximum length of byte[]?

后端 未结 4 790
孤独总比滥情好
孤独总比滥情好 2020-12-09 09:04

I\'m trying to create an array of bytes whose length is UInt32.MaxValue. This array is essentially a small(ish) in-memory database:



        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-09 09:19

    The current implementation of System.Array uses Int32 for all its internal counters etc, so the theoretical maximum number of elements is Int32.MaxValue.

    There's also a 2GB max-size-per-object limit imposed by the Microsoft CLR.

    A good discussion and workaround here...

    • BigArray, getting around the 2GB array size limit

    And a few related, not-quite-duplicate, questions and answers here...

    • Is there a limit of elements that could be stored in a List ?
    • Very large collection in .Net causes out-of-memory exception
    • what is the max limit of data into list in c#?

提交回复
热议问题