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

后端 未结 3 476
佛祖请我去吃肉
佛祖请我去吃肉 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:34

    I am using a concurrentdictionary to rank 3x3 patterns in half a million games of go. Obviously there are a lot of possible patterns. With C# 4.0 the concurrentdictionary goes out of memory at around 120 million objects. It is using 8GB at that time (on a 32GB machine) but wants to grow way too much I think (tablegrowths happen in large chunks with concurrentdictionary). Using a database would slow me down at least a hundredfold I think. And the process is taking 10 hours already.

    My solution was to use a multiphase solution, actually doing multiple passes, one for each subset of patterns. Like one pass for odd patterns and one for even patterns. When using more objects no longer fails I can reduce the amount of passes.

    C# 4.5 adds support for larger arraysin 64bit by using unsigned 32bit pointers for arrays (the mentioned limit goes from 2 billion to 4 billion). See also http://msdn.microsoft.com/en-us/library/hh285054(v=vs.110).aspx. Not sure which objects will benefit from this, List<> might.

提交回复
热议问题