hi !!
i have a form with 4 grid that are connected to each other via data relations.
the grid have some checkboxes, textfields and dropdowns.
total around 10 datatables.
when user clicks reload on data and to a grid.datasource = ds on the tables again. for some reason the data isnt released.
1. is it possible to prevent initializelayout to be called (first time should be enough) ?
2. whats the correct way of doing this ?
i use 2008 vol 3, but have also tried with 2010 vol 2.
regards,
Geir Sanne
Hi,
I dropped the number of iterations down to 200, because if there's a leak here, it should not matter how many times you do it, the leak should be obvious with just a few iterations.
I then ran your sample with the sci-tech .Net Memory profiler and I see no increase in the number of BindingContext objects. There is, in fact, only 1 created, and it is properly disposed. This happens even if I don't dispose the DataTable.
What memory profiler are you using to determine that there is a leak here? Can you provide moredetails about the results?
If you are getting multiple BindingContext objects and you want to rule out the grid, try doing the same test using the DataGridView control instead of the UltraWinGrid and see if you get the same results.
ive now removed the doevents and i dispose the dataset, but there is no difference.in windbg i can still se the same objects and the mem usage doesnt go back to where it started.
i can see in windbg that there are a lot of bindingcontext objects. is this something infragistics leaves there or is it .net ?
Why is your sample 1MB? Can you reduce it down any further? There's no reason why any code sample should be that big unless you are including a database or assembly files which should not be necessary to duplicate the issue.
Anyway, I took a look at your sample and there are a few things I noticed right away. The first is that you are using Application.DoEvents. I've never heard of this causing memory issues, but it certainly can cause timing problems and issues with the order of events. Microsoft's documentation even warns against using this method unless you are extremely careful. So if your real application is using DoEvents, try taking it out and see if that helps.
The other thing is, you are not disposing of the DataSource in the sample. So memory usage in this sample will certainly go up because the code has a memory leak.
If you remove the DoEvents and dispose of the DataSet before creating the new one, does the leak still occur?
ive tried to remove the code in initlayout and row, but mem usage still grows.
ive tried to upload some sampel code but its 1MB, and max upload size is 200kb.
so ive just created a new windows forms project, dragged a ultragrid to the form
and then do grid.datasource = newdataset; 500 times.
mem usage is then still growing, but not as much as in the full sample project.
This could be something in InitializeLayout, or InitializeRow, or it's always possible that there's a bug in the grid. Without a sample demonstrating the issue, we have no way to know.
If it is the InitializeLayout or the InitializeRow event, though, this should be very easy for you to check. Just comment out the code in those events and see if the problem goes away.
Of course, it's still possible that you are doing everything right in those events and the grid still has a hole somewhere, but if so, it's not one we are aware of.