Memory Leak w/Infragistic Grid

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
Posts: 2
Joined: Tue Feb 16, 2010 8:48 pm

Memory Leak w/Infragistic Grid

Post by tanderson66 » Thu Feb 18, 2010 9:49 pm

I have a child form with an Infragistics UltraGrid that I set the datasource with the following code (in the child form):

_dsHelp = Common.GetChimpHelp(this.Name)

In the Common project the code is this:

Code: Select all

            dsSvr = new DataSet();
            string conString = System.Configuration.ConfigurationManager.AppSettings["DP2"];
            SqlConnection con = new SqlConnection(conString);
            SqlCommand cmd = new SqlCommand("spQ_ChimpHelpByFormName", con);
            cmd.CommandTimeout = 300;
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@FormName", _formName);

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            return (dsSvr);
If I take a snapshot after closing the child form my grid is still in memory do to being directly rooted by an event handler.

If I move the code from Common to the child form, I don't get this error. I am not sure what to do to fix the code
so I can have it in the Common project and not get the Event handler condition.

Following is the allocation stack:

System.Windows.Forms!System.Windows.Forms.BindingContext.EnsureListManager( object,string )
System.Windows.Forms!System.Windows.Forms.BindingContext.get_Item( object,string )
Infragistics2.Win.UltraWinGrid.v5.3!Infragistics.Win.UltraWinGrid.UltraGridBase.Set_ListManager( object,string )
Infragistics2.Win.UltraWinGrid.v5.3!Infragistics.Win.UltraWinGrid.UltraGridBase.set_DataSource( object )
HRIChimp.Win.SubjectInfo!HRIChimp.Win.SubjectInfo.SubjectInfo.PopulateHelp() SubjectInfo.cs
HRIChimp.Win.SubjectInfo!HRIChimp.Win.SubjectInfo.SubjectInfo.SubjectInfo_Load( object,EventArgs ) SubjectInfo.cs
System.Windows.Forms!System.Windows.Forms.Form.OnLoad( EventArgs )
HRIChimp.Win.Common!HRIChimp.Win.BaseForm.OnLoad( EventArgs ) BaseForm.cs
System.Windows.Forms!System.Windows.Forms.Control.CreateControl( bool )
System.Windows.Forms!System.Windows.Forms.Control.WmShowWindow( ref Message )
System.Windows.Forms!System.Windows.Forms.Control.WndProc( ref Message )
System.Windows.Forms!System.Windows.Forms.ScrollableControl.WndProc( ref Message )
System.Windows.Forms!System.Windows.Forms.ContainerControl.WndProc( ref Message )
System.Windows.Forms!System.Windows.Forms.Form.WmShowWindow( ref Message )
System.Windows.Forms!System.Windows.Forms.Form.WndProc( ref Message )
System.Windows.Forms!System.Windows.Forms.Control.ControlNativeWindow.OnMessage( ref Message )
System.Windows.Forms!System.Windows.Forms.Control.ControlNativeWindow.WndProc( ref Message )
System.Windows.Forms!System.Windows.Forms.NativeWindow.Callback( IntPtr,int,IntPtr,IntPtr )
[Native to managed transition]
[Managed to native transition]
System.Windows.Forms!System.Windows.Forms.UnsafeNativeMethods.IntCreateWindowEx( int,string,string,int,int,int,int,int,HandleRef,HandleRef,HandleRef,object )
System.Windows.Forms!System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx( int,string,string,int,int,int,int,int,HandleRef,HandleRef,HandleRef,object )
System.Windows.Forms!System.Windows.Forms.NativeWindow.CreateHandle( CreateParams )



Andreas Suurkuusk
Posts: 1031
Joined: Wed Mar 02, 2005 7:53 pm

Re: Memory Leak w/Infragistic Grid

Post by Andreas Suurkuusk » Fri Feb 19, 2010 3:48 pm

It's hard to tell what the problem is using the information you provided. Just moving code from one place to another should not affect whether instances will be GCed or not. However, if you store references in other fields the instance lifetime will be affected. For instance, in your example code you didn't declare the DataSet reference "dsSvr". Is it a local variable, a member field or a static field? If it's not a local variable, then moving the code between the child form and the Common project can affect the lifetime of instances. I can imagine that the UltraGrid adds an event handler to its datasource, and if the lifetime of the datasource changes, this will affect the UltraGrid, and the whole Form it belongs to.

Which instance is associated with the callstack? The grid or the event handler? When investigating a memory leak it's usually best to investigate the root path first. It will tell you why the instance has not been GCed. If you provide one of the root paths of the grid, maybe I can give you some better information about your problem.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 11 guests