Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1065
ValueLists are still in Memory afte changing UltraGrid.DataSource
posted

Hello,

I've noticed a problem concerning the valuelists which ultragridcolumn can have.

In my case I have a UltraTree where the user can choose a tablename.
Depending on the user's choice a dataset will be filled and set as datasource for a bindingsource.
Then this bindingsource will be set as the UltraGrid's datasource. Everything works fine.

But some of my tables have valuelists. I create them after setting the UltraGrid's datasource by calling a sub called "LoadvalueLists" which is running these steps for each needed valuelist:

1. Instancing and filling a datatable "dt"
2. Instancing a UltraDropDown "udd"
3. Setting udd.Datasource = dt
4. Setting udd.ValueMember = dt.Columns(0).ColumnName and udd.DsiplayMember = dt.Columns(1).ColumnName
5. Column.Valuelist = udd

When the user changes betwenn the tables the memory usage increases without ever giving the memory free so the memory gets overloaded after a time. I observed this behaviour by using a process explorer which shows me the momery usage of a certain process.

If I don't call "LoadValueLists" the memory usage increases and decreases again constantly. To prevent the memory usage increasing I can also run the following code before setting the new UltraGrid's datasource:

For Each Band As UltraGridBand In Me.UltragGrid1.DisplayLayout.Bands
    
For Each Column As UltraGridColumn In Band.Columns
         
If Column.ValueList IsNot Nothing Then
              
TryCast(Column.ValueList, UltraDropDown).Dispose()
              
Column.ValueList = Nothing
         
End If
    
Next
Next

This seems to me like a bug. The UltraGrid should not keep the Column's ValueList informations alive after his datasource has been changed.

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi,

    The grid cannot make the assumption that an UltraDropDown control that you created is no longer needed simply because the grid column is no longer using it. What if som,ething else in your code tried to use that UltraDropDown for another grid? Or tried to re-use the same UltraDropDown for a different column in the grid with the new data source?

    As a general rule, if you create a control, you are responsible for disposing it. So this is not a bug and your code here which disposes the UltraDropDown controls is correct.

     

Children
No Data