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
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.
Thanbks for your quick reply.
The DataSet is new each time.
So, when I call:
DataSet oDS = GetMeSomeData()
ultraGrid1.SetDataBinding( null, null )
ultraGrid1.SetDataBinding( oDS, null )
is my original DataSet still in existence?
I'm not familiar with the BindingManager (even though I have used Wingrid for years). Is this something that I have to get rid of?
Hi Dimitar
I removed the UI provider from my form and the app works fine. No more UltraGridColumns held in memory. I can refresh the grid as many times as I like. However, I need the Excel column filters facility, so this is what I've done (inside my LoadGrid() method):
UltraGridFilterUIProvider oColFilterUI = ultraGrid1.DisplayLayout.Override.FilterUIProvider; if (null != oColFilterUI) { oColFilterUI.Dispose(); } ultraGrid1.DisplayLayout.Override.FilterUIProvider = null;
oColFilterUI = new Infragistics.Win.SupportDialogs.FilterUIProvider.UltraGridFilterUIProvider(); ultraGrid1.DisplayLayout.Override.FilterUIProvider = oColFilterUI;
The UI provider is now not a form-level variable. Is there anything wrong with calling Dispose() on it each time I refresh the grid?
So close! Having made those changes I can now refresh the screen as many times as I like. But if I apply some column filters (e.g. starts with 1) I can only refresh the screen 3 times before the app crashes.
With no column filters I can watch the app with the Task Manager as as the memory builds up I can see it decrease as the GC kicks in. It works consistently - the memory hovers around 1.2M
As soon as I use column filters the memory keeps going up and I never see it going down
Where should I look next?
That sounds like a bug to me. Can you post a small sample project demonstrating this so we can take a look?
Thanks Mike
I'm trying to reproduce this in a test project. I can reproduce the problem with UltraGRidColumns being held in memory if the FuilterUIProvider is a form-level variable, but you need a memory profiler to see the results.
I can't reproduce the problem that I see whenever column filtering is used. My app is pretty consistent. By making the FilterUIProvider not a form-level object I can refresh the screen as many times as I like. As soon as I type "X" in a column filter I can only refresh it twice.
I will keep trying.
Hello,
I am just checking about the progress of this issue. Have you been able to isolate the issue in a separate sample? Let me know if you need any further assistance on this issue.
Thank you for using Infragistics Components.