Fundamental Design Question

I think I need some guidance with from someone with more experience than me…

Some Background:
I have a canvas used to scroll container controls using EmbedWithin() and Scroll(), and there could be potentially thousands of the container controls. The container control has a total of 26 text fields and labels, and when clicked the container expands vertically and allows editing.

I am worried about the memory requirements and the UI responsiveness of having thousands of these container controls.

It takes 6 seconds to instantiate and embed 300 of the container controls, and 55 seconds for 1000 (so it’s not a linear relationship). I’ve considered threading this part.

A much bigger problem is App memory - with 300 controls memory usage balloons to about 230MB initially, then drops to about 140MB. With 1000 controls memory peaks at about 2GB, then drops to 350MB.

It also takes much longer than the instantiate/embed times for the main app window to appear. For 1000 controls, it takes about 3 minutes. I am guessing this is because the framework or the OS is doing something with drawing the controls.

Once the app gets through all that and the controls are displayed, they scroll nicely and there doesn’t seem to be any performance issues.

My Question:
Can I somehow avoid the memory/delay issues with this approach?

Plan B:
Or should I embed enough controls to fill the canvas and then “scroll” them by simply changing the data they display?

UI with hundreds or thousands of controls then you can always be sure there is something not all right in the design.

If you look at Table sources in iOS for example then they re-use the rows.

If the UI is more irregular than so you can solve it with a few standard row types and recycling so there are never more than the screen can display at once, then other way would be to try to custom render the canvas in some way.

my bet is that you should do that

How long does it take to create a single control? I would consider either Plan B - change what your controls display or create controls on the fly and destroy others.

So when something scrolls off the page, destroy it and when something new scrolls onto the page, create it.

It might just be simple though to create a display of however many controls you decide should be shown at one time. Then have a class that updates the control. Keep in mind, you can create a class for all your data and then create thousands of these that are objects representative of whatever data you want to display. So create a class that has like a dictionary that contains all the info in the text fields for a particular control, etc. You can add methods and events to these classes, etc. Store them in an array or dictionary and use their data to update the display when you change the scrolling.

I think creating the objects that are not graphical will involve far less memory than storing all those container controls.

have a database (eventually in memory) to store the control’s datas.
refresh the display only to what’s visible to the user, so the height of the canvas.
so the UI should be completely fast.
I’ve done this with millions of rows in a database listbox. works like a charm.

Thanks for the replies. I was coming to the same conclusion that you all have - that keeping 1000’s of container controls in memory is crazy.

I think I will try the iOS Table approach where the controls are created/destroyed as they scroll into/out of the canvas. Updating data in static controls would probably be easier, but I think I want the UI visual of the controls actually scrolling.

Thanks again - I appreciate your experience.

And please change the channel to General - there is no reason for this question to be in the Pro channel.

[quote=386193:@Jean-Yves Pochez]have a database (eventually in memory) to store the control’s datas.
refresh the display only to what’s visible to the user, so the height of the canvas.
so the UI should be completely fast.
I’ve done this with millions of rows in a database listbox. works like a charm.[/quote]

Would be somewhat more helpful if you explained how … :wink:

took some time (months) to make it work like I wanted … :wink:

mainly you make use of the LIMIT and OFFSET keywords in your sql query to select only the visible items
you need a container control with hrozontal and vertical scrollbar and your want-to-scroll listbox or canvas.
then it’s a game between the 3 items and their events…

this is done with such a control :

I certainly can do that. But what sort of questions belong in the Pro channel?

The “Pro” forum is the place where you place professional related questions and ideas that really pertain just to pro users - not stuff that is of general interest.

And if you ask me for a “Pro” example then I don’t have one. In my opinion the “Pro” channel was a marketing exercise … which badly went wrong when people started asking general questions in it because they thought that was the proper channel because they have a “Pro” license …