views:

156

answers:

4

Hello,

What is the maximum amount of data I can load onto a form control?

My application consumes too much memory and hangs when more than 500,000 records are added to any windows forms control in my experience. Any clues?

Thanks

+6  A: 

Yes, that will cause problems.

Don't add that many records.

Nobody needs that many. What you need to do instead is add filtering capabilities so that the user can specify which range of the data he/she wants to use.

For instance, let the user narrow the search by date (if it's time-sensitive data), or order number range, or ... well, whatever.

But I can guarantee you that finding a way to add 500K rows to a grid or whatever is not a solution.

Lasse V. Karlsen
+1 for pointing out that "If you have to ask, you're probably doing something wrong." (http://blogs.msdn.com/oldnewthing/archive/2007/07/18/3926581.aspx).
Grant Wagner
This is the link I was looking for when I found the first one: http://blogs.msdn.com/oldnewthing/archive/2007/03/01/1775759.aspx
Grant Wagner
+3  A: 

Looks like you've found the maximum memory footprint of your app.

There is no single measure.

Application memory includes also GDI handles, File Handles, Threads that your app is using. Make sure you don't have a GDI handle leak using Task Manager and likes.

Also it's not a good practice to load 500,000 records to the UI, the user can never handle so much information, please change your practice by using paging or other ways for that tasks.

ArielBH
A: 

Something I normally do is limit the number of records shown on the screen, usually to 20, but it depends on the type of data you're trying to show.

I normally apply filtering after this, and return the data and a revised recordcount to the application. If the user wants to be able to see all the records, they can export to another application (usually Excel, which would break, but also XML.)

Nobody is going to read through half a million records, though.

Hooloovoo
A: 

That is a big pile of data; the first thing to do is, indeed, to reduce the amount of data - however, since you mention DataGridView in the tags, there is "virtual mode" for large data scenarios. See on MSDN, here (overview) and here (howto).

Some (but not all) other list-based controls also have "virtual mode" support.

Marc Gravell