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 Geir,
There's very little information here to go on. Are you disposing the DataTables you created in your DataSet when you create new ones?
goggi said:1. is it possible to prevent initializelayout to be called (first time should be enough) ?
InitializeLayout fires any time the grid's DataSource/DataMember are changed or any time the DataSource sends a reset notification. It's not supposed to only fire the first time - that would defeat the purpose of the event.
You could skip the code in this event using a flag if you want, or you could disable the event using the grid's EventManager. But that's not really how it is intended to work and it seems like a very odd thing to do. I don't understand how that would help you.
goggi said:2. whats the correct way of doing this ?
Correct way of doing what, exactly? Binding and then re-binding the grid? There's no one single correct way, it depends on the needs of your application. But if your application is leaking memory, then it's mostly likely because you are creating objects that you are not properly disposing of. These will get cleaned up by the DotNet garbage collector at some point, anyway, so it's usually not a big deal, unless your application is constantly increasing memory usage to the point where this affects the system as a whole.
ive tried to dispose the old datasets, but there is no difference when i do dispose and when i dont. they get disposed after a while anyway.
so if i want to reload data i can just do grid.datasource = ds; ?
and then the old layouts, bands, columns, etc. should be disposed by itself ?
i have a form with the grids where i reload the data every 10 seconds. i let it stay like this for 24 hrs.
then i stop the autorefresh and force a couple of GCs, but still the app uses about 100 MB more than when i started the app.
in windbg i can see that these types increase in size :System.EventHandlerSystem.Stringsystem.ControlEventHandlerSystem.ObjectMouseEventHandelrWeakReferenceUltraGridUIElementUltraWinGrid.CaptionAreaUIElemenTInfragistics.Win.UltraWinGrid.DataAreaUIElementInfragistics.Win.ControlUIElementBase+MouseEventManager
ive tried to look at all the types that increase but everything points to a infragistics .dll so im not sure what to do.
EEClass: 04a86b28Module: 003cebc0Name: Infragistics.Win.ControlUIElementBase+MouseEventManagermdToken: 02000111File: C:\Windows\assembly\GAC_MSIL\Infragistics2.Win.v10.2\10.2.20102.2058__7dd5c3163f2cd0cb\Infragistics2.Win.v10.2.dllBaseSize: 0x28ComponentSize: 0x0Slots in VTable: 19Number of IFaces in IFaceMap: 1--------------------------------------MethodDesc Table Entry MethodDesc JIT Name7181a7e0 715f4934 PreJIT System.Object.ToString()7181e2e0 715f493c PreJIT System.Object.Equals(System.Object)7181e1f0 715f495c PreJIT System.Object.GetHashCode()718a1600 715f4970 PreJIT System.Object.Finalize()718b5aa0 71677f58 PreJIT System.MarshalByRefObject.GetLifetimeService()71817e94 71677f60 PreJIT System.MarshalByRefObject.InitializeLifetimeService()7185bf0c 71677f68 PreJIT System.MarshalByRefObject.CreateObjRef(System.Type)06aa3a60 0147ca5c JIT Infragistics.Shared.DisposableObject.Dispose()067ede90 04ac2d5c JIT Infragistics.Win.ControlUIElementBase+MouseEventManager.OnDispose()04e0cd20 04ac2d64 JIT Infragistics.Win.ControlUIElementBase+MouseEventManager.HookControl(System.Windows.Forms.Control)0162ff1d 04ac2d6c NONE Infragistics.Win.ControlUIElementBase+MouseEventManager.UnhookControl(System.Windows.Forms.Control)0162ff80 04ac2d50 JIT Infragistics.Win.ControlUIElementBase+MouseEventManager..ctor(Infragistics.Win.ControlUIElementBase)067f77b0 04ac2d74 JIT Infragistics.Win.ControlUIElementBase+MouseEventManager.StartTimer(System.Windows.Forms.Control)067f7830 04ac2d80 JIT Infragistics.Win.ControlUIElementBase+MouseEventManager.StopTimer()04df1a68 04ac2d8c JIT Infragistics.Win.ControlUIElementBase+MouseEventManager.OnMouseEnter(System.Object, System.EventArgs)04df1a78 04ac2d98 JIT Infragistics.Win.ControlUIElementBase+MouseEventManager.OnMouseLeave(System.Object, System.EventArgs)04df1a88 04ac2da4 JIT Infragistics.Win.ControlUIElementBase+MouseEventManager.OnMouseMove(System.Object, System.Windows.Forms.MouseEventArgs)04df1a58 04ac2db0 NONE Infragistics.Win.ControlUIElementBase+MouseEventManager.OnMouseWheel(System.Object, System.Windows.Forms.MouseEventArgs)067f77c0 04ac2dbc JIT Infragistics.Win.ControlUIElementBase+MouseEventManager.OnTimerTick(System.Object, System.EventArgs)
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.
i use windbg as profiler.my bad. i just saw bindingcontext..didnt see the hashkey after.
ive uploaded the sample code (more like the one we use in real app). this use about 20 mb when it starts and the memory usage just increases. when i run sci-tech it says something about direct event handler roots(infragistics.win.controluielementbase.mouseeventmanager).ive tried to remove all eventhandlers i have, but i still get this error.for some reason this doesnt occur in the last sample i sent.
there are a lot of other extra objects in memory too.. is it supposed to be like this.. no memory is freed until mem usage reaches max mem in my computer ?
i will try to run the app for 1 week see if i still get out of memory exception.
Did you try this with the MS DataGridView? I'm pretty sure the WinGrid has no control of BindingContext HashKey objects. That looks like something internal to the BindingContext. It's possible that the WinGrid causes more of these to be created than the DataGridView, since the WinGrid show hierarchical data and the DataGridView is just flat. But there's not much we can do about that.
The MouseEventManager could be an issue in the grid, but it's something we would have to look into at length and I won't be able to do that in a forum post.
I'm going to forward this thread over to Infragistics Developer Support so they can write this up for developer review using your new sample.
Here's a sample project that shows a memory leak.
1) Click on the [New Data] button a few times right at he start, no leak.2) Filter the third coumn, select "hello2"3) Click on the [New Data] button afterwards... now there are leaking objects. And there are more leaks added eevry time you click the button after that one filtering.
The DataTable is disposed.
Did anything come from this? I am having an issue with UltraCombo in that each time I set the datasource, the InitializeRow() event fires for the new data as well as the previous data as well. So, each time the DataSource is set using SetDataBinding(), the number of times the InitializeRow() fires grows based on how many records are in the different datasources.
SetDataBinding having 1 record, InitializeRow fires once.SetDataBinding having 2 records, InitializeRow fires three times.SetDataBinding having 1 record, InitializeRow fires four times.
We are using version 8.1 of the WinForm controls.
Thanks for any light you can shed on this...
This doesn't sounds like it's related to the previous posts in this thread. I don't remember hearing of anything like this happening before.
What kind of DataSource are you using here?
Are you using the same instance and adding/removing rows of data? Or are you creating a completely new instance of a data source?
I can't imagine anything you could be doing in you code that would cause this behavior, unless you are simply adding rows to the existing data source without realizing it. Assuming that is not the case, then it seems like it's probably a bug in the 4-year-old version of the controls you are using. You could try getting the latest service release.
Can you post a small sample project demonstrating this behavior? If so, we could try it out and tell you for certain.
If not, then you may want to try getting the latest service release or updating to a new version of NetAdvantage.
How to get the latest service release - Infragistics Community