I hit an OutOfMemoryException with List - is this the limit or am I missing something?

前端 未结 3 943
臣服心动
臣服心动 2021-01-04 05:00

Given the opportunity to rewrite, I would, but anyway, the code as it stands:

List foobar;

Then we add a bunch of strings to

3条回答
  •  感动是毒
    2021-01-04 05:58

    If you're trying to use very large lists in 64 bit environments you need to enable large objects in the application configuration.

    http://msdn.microsoft.com/en-us/library/hh285054.aspx

    The OOM is likely due to the way Lists/ArrayLists allocate memory, which I believe is each time their boundary is reached, they attempt to double in size. The list cannot double from 2^24. You could theoretically maximize your list size by pre-specifying a size. (I.e. 2GB)

提交回复
热议问题