Josh
Josh

Reputation: 13828

What is the maximum amount of data that can be loaded into a Windows form control?

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?

Upvotes: 2

Views: 439

Answers (4)

Marc Gravell
Marc Gravell

Reputation: 1063298

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.

Upvotes: 1

Hooloovoo
Hooloovoo

Reputation: 2181

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.

Upvotes: 0

ArielBH
ArielBH

Reputation: 2001

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.

Upvotes: 3

Lasse V. Karlsen
Lasse V. Karlsen

Reputation: 391446

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.

Upvotes: 6

Related Questions