tags:

views:

81

answers:

4

Hi all,

Facing an issue where in the user objects goes more that 10000 in windows app and the app crashes.

After much analysis we realized that we need to get rid of the panels that we use to align the controls and may be reduce the possibility of user objects reaching 10000.

Our App UI is dynamically generated driven by a configuration and it can vary. So all the UI generation is happening dynamically.

Any help would be much appreciated

+1  A: 

Just as a note, the Chrome development team hit this problem too, and the scroll bar arrows (among other things) weren't drawing anymore when some internal gdi limit was hit. It is quite possible to hit this limit in a complex enough gdi app.

You might want to do some research and see how they fixed it.

As an alternative, you could consider using a different platform, either gtk or wpf would do fine and they don't use gdi handles to draw.

Blindy
Any links or references on that?
Joey
About the Chrome thing? There was a long bug report on their bug tracking system a while back, I can't remember the name off the top of my head, and it almost made me quit using it even though it's so fast, but they eventually fixed it!
Blindy
I've heard this before, if that counts for anything.
Snarfblam
A: 
Snarfblam
+2  A: 

This is an unfounded suggestion, but remember to make sure that unneeded Controls always detach themselves from events they are be subscribed to. A Control that's still subscribed to an event of an "active" (what's the right term?) object can't be cleaned up.

frou
+1 This is something that cannot be stressed enough, but is often overlooked.
Groo
A: 

I'm guessing this from your question, but you're probably putting this large number of controls on a scrollable panel or a tab control with multiple tab pages, which means that most of these controls aren't actually visible to the user at any given point in time (because they couldn't possibly all be visible at once).

If you have all of these controls on a scrollable panel, one possible solution is to only load and display the controls that are on the visible portion as the user scrolls around in the panel. As the user scrolls, you would unload and dispose the controls that are no longer visible.

If you have all of these controls in a multi-page tab control, you can use a similar strategy and only load the controls on a tab page when that page is made visible (and unload the controls from the previous top-most tab page at the same time).

Another general strategy is to break up your one monster form into a large number of UserControls, and only show one of these UserControls at a time.

MusiGenesis
Thank you all. I agree with all of ur views about may be trying out with WPF or redesigning the whole UI but what we need is something of a intermediate fix. We decided to replace all the panels with TabelLayoutPanel for the allignment and the results are amazing. The userobject count comes down in good numbers.
Vinod Parameswaran