We have an UltraGrid which is bound to an UltraDataSource and LoadStyle is set to LoadOnDemand. We have been profiling the grid to minimise memory usage and noticed when the grid scrolls and you compare the memory footprint to when the grid first loaded, the extra memory is mainly attributed to UltraGridCells, Visible Headers and SubObjectPropChangeEventHandlers (in order of greatest change in memory). Our grid has about 8000 rows and 75 columns.
As the grid is load on demand:
1. Why does it create more ultra grid cells when the user scrolls and not reuse the ones it already has in view?
2. Is there a way to reduce the memory used while scrolling?
3. I tried to find the NetAdvantage example / tutorial on Load On Demand but for our company it seems to no be installed. Is there another way i can see the guide to Load On Demand?
Thanks
Hello,
Please let me know if you have further questions in this matter.
grasshopper said:1. Why does it create more ultra grid cells when the user scrolls and not reuse the ones it already has in view?
Because the ones that were in view are still in use. The grid cannot assume that just because a cell is out of view that it is no longer needed.
The grid doesn't necessarily know that those cells were created because they were scrolled into view. Cells are created lazily as they are needed. So, for example, if you set a property (like Appearance) on the cell, the cell gets created and it has to stay around to maintain that property setting.
grasshopper said:2. Is there a way to reduce the memory used while scrolling?
There is a method on the UltraGridRow called DeallocateCells which you may be able to use.
You would have to detect when the row is scrolled out of view. You could use the Before/AfterRowRegionScroll events for that.
Of course, if you are setting properties on the cells that need to be maintained, this will not work. But even if you are applying appearances to cells in the InitializeRow event, it might be okay, since I think the event will fire again when the row is scrolled back into view. Or... if it does not, you could always make it fire by calling Refresh on the row when it is scrolled into view.
grasshopper said:3. I tried to find the NetAdvantage example / tutorial on Load On Demand but for our company it seems to no be installed. Is there another way i can see the guide to Load On Demand?
The only way I know of would be to reinstall and choose to install the samples. But I will ping someone in Developer Support to see if there's another way.