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

前端 未结 3 937
臣服心动
臣服心动 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:55

    If it's getting even fewer than 2^24 when you manually set the correct list size then that's probably on the right track. Instead of getting to 16 million and then trying to double the size of the list, it'll be making the list really large to begin with and running out of memory earlier.

    That explains why you were getting a round number - it reached the 2^24 then tried to increase in size, which caused it to use too much memory.

    Sounds to me like it's some kind of 'natural' object size limit, as opposed to one in the implementation of the list.

提交回复
热议问题