Quaneu
2016-07-08T11:47:14Z
Hello,

Memory leaks in iGAutoFilterManager:
There is a ToolTip "fToolTip" but there is no call fToolTip.Dispose(). A further problem are Fonts in iGAutoFilterManager, there are also no Dispose calls.

An why is Dispose with "new" implemented and not

protected virtual void Dispose(bool disposing)

overridden?


Memory leaks in iGScrollBarBase:
There is a Timer "fTimer" but there is no call fTimer.Dispose().

Best regards
Quaneu
Igor/10Tec
2016-07-11T08:09:44Z
Thank you for your interesting comment. As I know, neither we nor our customers experienced memory leaks related to these things. Have you ever faced this problem in your apps and know how to reproduce/observe it?

In any case, I agree that we may need to add additional cleanup code to the existing iGrid and its add-ons. I'm going to do that in the forthcoming update. Can we discuss the details in a private email correspondence?
Quaneu
2016-07-11T08:24:26Z
Quote:

Have you ever faced this problem in your apps and know how to reproduce/observe it?


Yes, our tests for the app throw now an OutOfMemoryException. With ANTS Memory Profiler for example we were able to find the problems.

With this code our tests throw no OutOfMemoryException.

		private static readonly Type _iGridType = typeof(iGrid);
		private static readonly Type _timerType = typeof(Timer);
		private const BindingFlags Flags = BindingFlags.DeclaredOnly | BindingFlags.Instance |
			BindingFlags.NonPublic | BindingFlags.Public;

		/// <summary>
		/// This code is necessary to workaround the memory leaks in the iGrid library.
		/// </summary>
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				DisposeTimerOfGrid("fAutoScrollTimer");
				DisposeTimerOfGrid("fAutoScrollSetCaptureTimer");
				DisposeTimerOfGrid("fRefreshMouseDataTimer");

				DisposeTimerOfScrollBar("fVScrollBar");
				DisposeTimerOfScrollBar("fHScrollBar");
			}
			base.Dispose(disposing);
		}

		/// <summary>
		/// This code is necessary to workaround the memory leaks in the iGrid library.
		/// </summary>
		private void DisposeTimerOfGrid(string timerFieldName)
		{
			FieldInfo autoScrollTimerField = _iGridType.GetField(timerFieldName, Flags);
			DisposeTimer(this, autoScrollTimerField);
		}

		/// <summary>
		/// This code is necessary to workaround the memory leaks in the iGrid library.
		/// </summary>
		private void DisposeTimerOfScrollBar(string scrollBarFieldName)
		{
			FieldInfo scrollBarField = _iGridType.GetField(scrollBarFieldName, Flags);
			object scrollBar = scrollBarField.GetValue(this);
			if (scrollBar != null)
			{
				Type scrollBarType = scrollBarField.FieldType;
				Type iGScrollBarBaseType = scrollBarType.BaseType;
				FieldInfo timerField = iGScrollBarBaseType.GetField("fTimer", Flags);
				DisposeTimer(scrollBar, timerField);
			}
		}

		/// <summary>
		/// This code is necessary to workaround the memory leaks in the iGrid library.
		/// </summary>
		private static void DisposeTimer(object timerOwner, FieldInfo timerField)
		{
			Timer timer = timerField.GetValue(timerOwner) as Timer;
			if (timer != null)
			{
				timer.Stop();
				timer.Dispose();
			}
		}

Quote:

Can we discuss the details in a private email correspondence?


Yes
Igor/10Tec
2016-07-11T09:02:20Z
"Out of memory" exception? Interesting! In what scenario? Did you create many copies of iGrid in a loop or so?
Quaneu
2016-07-11T09:20:07Z
No. We have Tests for our App. In this tests we create view and the controller and test the logic. These tests a very fast and therefore many views (with iGrid(s)) generated in a short time.
Quaneu
2016-08-01T08:21:48Z
In an internal build of iGrid.NET all memory leaks we found were solved. Many thanks for the quick help.