i want to display 1000000 records in a grid view at a time in one page ..so what i do
it give out of memory exception
Loading
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.
priya AvanigaddaPosted Jan 7, 2015, 1:17 AM
akash singhPosted Jan 7, 2015, 12:37 AM
Wim SturkenboomPosted Jan 3, 2015, 8:06 AM
Manish Kumar ChoudharyPosted Jan 3, 2015, 4:38 AM
akash singhPosted Jan 3, 2015, 4:34 AM
Manish Kumar ChoudharyPosted Jan 3, 2015, 1:10 AM
Hi akash singh,
If you can't fit your entire data set in memory, then you need a buffering scheme. Rather than reading just the amount of data needed to fill the DataGridView in response to CellValueNeeded, your application should anticipate the user's actions and read ahead. So, for example, when the program first starts up, it should read the first 10,000 records (or maybe only 1,000 or perhaps 100,000--whatever is reasonable in your case). Then, CellValueNeeded requests can be filled immediately from memory.
As the user moves through the grid, your program as much as possible stays one step ahead of the user. There might be short pauses if the user jumps ahead of you (say, wants to jump to the end from the front) and you have to go out to disk in order to fulfill a request.
That buffering is usually best accomplished by a separate thread, although synchronization can sometimes be an issue if the thread is reading ahead in anticipation of the user's next action, and then the user does something completely unexpected like jump to the start of the list.
16 million records isn't really all that many records to keep in memory, unless the records are very large. Or if you don't have much memory on your server. Certainly, 16 million is nowhere near the maximum size of a List, unless T is a value type (structure). How many gigabytes of data are you talking about here?