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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Jan 2, 2015, 8:10 PM EST
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?
akash singh119 reputationPosted Jan 2, 2015, 11:34 PM EST
akash singh119 reputationPosted Jan 6, 2015, 7:37 PM EST
priya AvanigaddaRank #7,836 · 233 reputationPosted Jan 6, 2015, 8:17 PM EST
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Jan 2, 2015, 11:38 PM EST
Wim SturkenboomRank #2,527 · 554 reputationPosted Jan 3, 2015, 3:06 AM EST