Hi,
We have a grid containing 130+ columns and 56K+ rows. We have implemented the LoadOnDemand as the LoadStyle and we are listening to the InitializeRow event in order to set the color scheme of the some of the cells within the row. We have changed our code to follow the recommendations within the WinGrid Performance Guide article.
If the user scrolls all the way down to the bottom of the grid, we get the following exception:
Thread exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.Collections.Hashtable.rehash(Int32 newsize) at System.Collections.Hashtable.expand() at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at System.Collections.Hashtable.set_Item(Object key, Object value) at Infragistics.Win.UltraWinGrid.UltraGridLayout.AddMulticastObjectHelper(Hashtable table, Object obj) at Infragistics.Win.UltraWinGrid.UltraGridLayout.SetMulticastAppearance(AppearanceBase appearance, Object obj) at Infragistics.Win.UltraWinGrid.UltraGridCell.set_Appearance(Appearance value) at NsbSystem.Windows.Forms.Grids.GridCell.set_ColorScheme(ColorScheme value)
Is there something we can do to avoid this exception?We are currently using version 12.1.20121.1001 of Infragistics.
That shouldn't matter, when CellDataRequested fires you can go into the Custom Collection and pull out the value being requested as the event args pass the information necessary to the event to determine what cell is being displayed. The InitializeRowsCollection event would also be used by asking your Custom Collection how many rows there are going to be if all the data for that set was loaded. The difference here is instead of binding the grid directly to your Custom Collection you bind the grid to the intermediary UltraDataSource and the UltraDataSource communicates with your Custom Collection.
Good afternoon,
I looked at the sample but unfortunately, I am not sure if I can apply the code there as we have implemented our very own custom collection that derives from IBindingList and ITypedList.
Annie
Did you get a chance to look at the load on demand sample in the samples browser?
Hi Annie,
What are you using as your datasource for the grid?
Using the LoadStyle of LoadOnDemand instead of PreloadRows is good when you have lots of rows but here you also have a lot of columns. Remember though that some operations, like sorting rows, will cause the all rows to be loaded regardless of the load style setting because they require access to all rows. For example if you have a summary that sums the values of a column then when the summary is calculated all the rows will be loaded.
Have you looked at the LoadOnDemand sample in the samples browser where the UltraGrid is bound to an UltraDataSource that uses CellDataRequested and InitializeRowsCollection to set the number of rows expected for that band? That sample also has a million cells.
Good morning,
I wrote up a small test application to try to reproduce the issue and was not successful. I guess the memory usage for this sample app is far less than our current application therefore even if I define a larger grid, I am not getting the exception.
Before this particular exception, I was getting a similar one which originated in our own code. We are using a hashtable as a caching mechanism. Since our grid could, in some scenarios, contain more than a million cells, I changed our code to prevent the hashtable to grow after it reach a certain limit. Once I fixed this problem, I got the other exception I sent you and this is the reason I was asking if there is something I can do to prevent it.