List vs. Dictionary (Maximum Size, Number of Elements)

后端 未结 3 451
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-14 11:09

I am attempting to ascertain the maximum sizes (in RAM) of a List and a Dictionary. I am also curious as to the maximum number of elements / entries each can hold, and their

3条回答
  •  爱一瞬间的悲伤
    2021-01-14 11:43

    I think you have bigger issues to solve before even wondering if a Dictionary with an int64 key will be useful in 5 or 10 years.

    Having a List or Dictionary of 2e+10 elements in memory (int32) doesn't seem to be a good idea, never mind 9e+18 elements (int64). Anyhow the framework will never allow you to create a monster that size (not even close) and probably never will. (Keep in mind that a simple int[int.MaxValue] array already far exceeds the framework's limit for memory allocation of any given object).

    And the question remains: Why would you ever want your application to hold in memory a list of so many items? You are better of using a specialized data storage backend (database) if you have to manage that amount of information.

提交回复
热议问题