We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Bind <--> Unbind - BUG - Resource Leaks Detected

Hi! I have been having trouble with binding and unbinding data to the data bound grid during the same interactive edit session on a form. I have been able to reproduce the behaviour in the very simply single form application, which I have included with this post. The bind and unbind buttons simply attach and detach from the data source. (In fact if you continuously press bind and un-bind the grid doesn’t render correctly.) The Bind/Unbind button simulates 1000 attaches and detaches to the grid, which really highlights the problem! Then when you press the update data source button, the time take to perform each updates really show that there is some sort of leak going on. I have included some debug output so you can see the time taken during each assignment. My 2c worth is that there is some sort of clean up issues going on inside the grid! Perhaps event handlers not being detached correct during the reset of the data source, which would result in this type of behaviour. I haven’t checked for memory leaks but I suspect that there would be some as well. I have included the option to select the MS grid as well to highlight the fact that the problem is a SyncFusion grid issue not a complex binding issue in general. In either case, we are impressed with the features that the SyncFusion grid offers however, our application does require binding and unbinding during the same UI session so we really do need to have this issue resolved. Any ideas for a work around while you guys look into a bug fix would be greatly appreciated! Thanks, Marcus.

3 Replies

AD Administrator Syncfusion Team August 16, 2003 07:04 AM UTC

After setting the DataSource = null, also set the ColCount = 0. grid.DataSource = null; grid.Model.ColCount = 0; What version of our code base are you using? In 1.6.1.0, with the above line added, I modified your sample by adding another label and displaying the ticks taken to do the 100 updates, and 1000 attaches/detaches. I saw no noticeable difference between doing the 100 update after the single binding, or after the 1000 bindings. The updating was probably 1/4 to 1/3 slower the the DataGrid update, but I think that is due to the drawing infrastructure that allows for drawing any font in any cell with any color and any border (etc) that the Syncfusion grid's supports and the DataGrid does not support. In fact, when you suspend the drawing during the updating, only drawing after the last update, the GridDataBoundGrid is 1/3 faster than the DataGrid. And this was true whether it was on the first binding or 1001 binding. Below is one of your button handler's showing commented suspend drawing code. Does adding ColCount = 0 resolve the problem as you see it?
private void button4_Click(object sender, System.EventArgs e)
{
	this.label3.Text = "";
	//grid.BeginUpdate();
	int ticks = Environment.TickCount;
	chkMode.Enabled = false;
	for (int i=0; i < 100; i++) 
	{
		Debug.WriteLine(i.ToString());
		m_DS.Tables["T1"].Rows[0]["C1"] = i.ToString();
	}
	//grid.Model.EndUpdate();
	//grid.Refresh();
	this.label3.Text = (Environment.TickCount - ticks).ToString() + " ticks";
}


IO IOMS August 17, 2003 08:37 PM UTC

Thanks for the quick reply! I am using version 1.6.1.0 (.Net Framework 1.1) OK – I tried what you suggested – but it seemed to make no difference (except that the UI problem has been solved). The good news is I have been able to find an effective work-around (still not sure about any additional resource leaks) Here are the results of my testing :- Original Program (with ticks added) Unbound : 297 ticks Bound : 484 ticks After Bind/Unbind x 1000 : 5422 After Another Bind/Unbind x 1000 : 8953 After Another Bind/Unbind x 1000 : 27140 After Another Bind/Unbind x 1000 : 86468 The times seem to be getting exponentially worse! ColCount = 0 Version Unbound : 265 ticks Bound : 453 ticks After Bind/Unbind x 1000 : 5578 After Another Bind/Unbind x 1000 : 10047 After Another Bind/Unbind x 1000 : 27328 After Another Bind/Unbind x 1000 : 70437 Again, a similar pattern! Finally, the work-around version :- grid.DataMember = ""; grid.DataSource = new DataSet(); Unbound : 328 ticks Bound : 453 ticks After Bind/Unbind x 1000 : 234 After Another Bind/Unbind x 1000 : 219 After Another Bind/Unbind x 1000 : 203 After Another Bind/Unbind x 1000 : 234 The results speak for themselves! I hope this information helps! I have attached my updated program, which was used to get the above results.


AD Administrator Syncfusion Team August 18, 2003 05:47 AM UTC

I must not be doing the same steps as you. I ran your code (unchanged) on two different systems using 1.6.1.0 and .NET 1.1 and 1.0, and I did not see the results you results you got. Here are the exact steps I take not changing anything else: 1) Bind/Unbindx1000 2) Bind 3) Update datasourcex100 4) Unbind 5) repeat steps 1-4 If I repeat steps 1-4 multiple times, the time in step 3 is essentially 500-600 msecs. There is no order of magnitude increases. What steps do you take? Are you running any special debugging tools or something? You do have that Console.WriteLine inside the 100-loop that will increase the total debug output with each click, but it did not affect anything on the systems I tried, only streaming to the output window.

Loader.
Live Chat Icon For mobile
Up arrow icon