Quote:
I have the below code
What code?
Memory - by its nature - is limited!
Before you ask yourself how to fill a list with 1 million records, ask yourself: 'what will I do with that list?'...
Present to the end user? No way any user can handle a list of 1 million items?
Save onto some other media (disk? DB?). Do it bu chunks/pages, that will save some memory for you...