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
1520
WinGrid Memory Management
posted

Hi

I'm trying to understand some memory problems with my app and I need a basic understanding of how wingrid manages memory.

I have a button which executes a SQL query and returns a DataSet. The DataSet obviously owns an amount of memory

I then bind the DS to the grid using:

ultraGrid1.SetDataBinding( null, null );
ultraGrid1.SetDataBinding( oDS, null );

Q1: Does wingrid copy all of the data from the DataSet into the grid? Is my original DS unchanged?

Q2: If I press the button a 2nd time to repeat I will get a 2nd DataSet. Is my original DS still in memory? Does it go out of memory when ultraGrid1.SetDataBinding( null, null ); is called?

If I look at the app using Task Manager the memory just keeps going up until I get an out of memory exception

Thanks

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    gstanbury said:
    Q1: Does wingrid copy all of the data from the DataSet into the grid? Is my original DS unchanged?

    No, and yes. The grid doesn'y create any kind of copy of the data, although the grid does create structures of it's own that will mirror the data source. For example, the grid will create bands and columns to represent the tables and fields in the data source. For the data itself, the grid will often request the data value of a particular field and put that data into a UIElement to display as a string or image, etc.

    The Datasource is not change in any way at this point (assuming you haven't changed any of the cells in the grid). But the DotNet framework will create a BindingManager to help communicate between data source and the grid and maintain the current position.

    gstanbury said:
    Q2: If I press the button a 2nd time to repeat I will get a 2nd DataSet. Is my original DS still in memory? Does it go out of memory when ultraGrid1.SetDataBinding( null, null ); is called?

    Pressing this button a second time will disconnect the grid from the DataSet and then reconnect it. No new DataSet is created (since you are still referencing the same oDS variable). Your original DataSet is still in memory (assuming nothing in your other code outside of this button disposed it).

    If the memory is increasing every time you do this, then it's possible it's a memory leak in the grid, or the BindingManager or in some other part of your code like one of the grid's event handlers.

Children