Hello,
Is there some technique, allowing to handle very long lists.
In my application when the length of a List surpasses a value about 16'000'000, the OutOfMemoryException is generated.
Regards.
Pavel.
Hello,
Is there some technique, allowing to handle very long lists.
In my application when the length of a List surpasses a value about 16'000'000, the OutOfMemoryException is generated.
Regards.
Pavel.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Akkiraju IvaturiPosted Sep 24, 2012, 11:37 AM
PavelPosted Sep 24, 2012, 4:53 AM
Akkiraju IvaturiPosted Sep 21, 2012, 12:02 PM
Without code it is hard to follow exactly what you are doing. I think many of the values are more than 85,000 byte threshold and so your objects endup on LOH and so the GC was not collecting the objects and as you continue processing objects you soon end up out of address space. FYI LOH is the normal source of OutOfMemoryException.
Or you might creating a string objects over and over in your code and so it is creating memory issue.
Or you might be performing many operations while adding data to list and processing it over and over.
If the reason is not known and could not resolve this I would advise you to use sequences and forget about lists. Rather than List
VulpesPosted Sep 21, 2012, 11:35 AM
If the objects are not too large, then one thing that may help is to set the List's initial capacity (in the constructor) to whatever number of items you think will eventually be reached.
If you do that then sufficient memory will be allocated on the 'large object heap' to accommodate this number of items in the List's internal array and no more allocations will be needed.
If you don't do it, then the List's capacity will be doubled from time to time as more space is needed by creating a new larger internal array and copying the old items into it. This means that at around 16 million items, a new array of 32 million items will need to be created and, even after a GC to get rid of the old one, it may not be possible to find sufficient memory on the LOH to accommodate the new array because (for performance reasons) the LOH is never compacted.