Hundreds of custom UserControls create thousands of USER Objects

Posted by Andy Blackman on Stack Overflow See other posts from Stack Overflow or by Andy Blackman
Published on 2010-06-10T15:23:33Z Indexed on 2010/06/11 8:43 UTC
Read the original article Hit count: 218

Filed under:
|
|
|
|

I'm creating a dashboard application that shows hundreds of "items" on a FlowLayoutPanel.

Each "item" is a UserControl that is made up of 12 or labels.

My app queries a database and then creates an "item" instance for each record, populating ethe labels and textboxes with data before adding it to the FlowLayoutPanel.

After adding about 560 items to the panel, I noticed that the USER Objects count in my Task Manager had gone up to about 7300, which was much much larger than any other app on my machine.

I did a quick spot of mental arithmetic (OK, I might have used calc.exe) and figured that 560 * 13 (12 labels plus the UserControl itself) is 7280. So that suddenly gave away where all the objects were coming from...

Knowing that there is a 10,000 USER object limit before windows throws in the towel, I'm trying to figure better ways of drawing these items onto the FlowLayoutPanel.

My ideas so far are as follows:

1) User-draw the "item", using graphics.DrawText and DrawImage in place of many of the labels. I'm hoping that this will mean 1 item = 1 USER Object, not 13.

2) Have 1 instance of the "item", then for each record, populate the instance and use the Control.DrawToBitmap() method to grab an image and then use that in the FlowLayoutPanel (or similar)

So... Does anyone have any other suggestions ???

P.S. It's a zoomable interface, so I have already ruled out "Paging" as there is a requirement to see all items at once :(

Thanks everyone.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET