Page 1 of 1

Memory-Leak StiReport.Design() found (and solved)

Posted: Wed Aug 28, 2013 9:52 am
by casic
Hi there,

I found a memory leak which occurs when using the Design() method of StiReport. After closing the report designer the instance StiDesignerControl is sill alive. This is caused by an event handler to the static event GoToCode of the StiReportChecker class.

The following code is a temporary solution to free up the report designer. I'm using the static event StiDesigner.ClosingDesigner for this purpose:

Code: Select all

	Private Shared Sub StiDesigner_ClosingDesigner(sender As Object, e As CancelEventArgs)

		Dim stiDesignerControl As StiDesignerControl = DirectCast(sender, StiDesignerControl)

		Dim fieldInfo As FieldInfo = GetType(Stimulsoft.Report.Design.Check.StiReportChecker).GetField("GoToCode", BindingFlags.Static Or BindingFlags.NonPublic)
		If fieldInfo IsNot Nothing Then
			Dim eventbindings As EventHandler = TryCast(fieldInfo.GetValue(Nothing), EventHandler)
			If eventbindings IsNot Nothing Then
				For Each d As System.Delegate In eventbindings.GetInvocationList()
					If Object.ReferenceEquals(d.Target, stiDesignerControl) Then
						Dim eventInfo As EventInfo = GetType(Stimulsoft.Report.Design.Check.StiReportChecker).GetEvent("GoToCode", BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.Static)
						If eventInfo IsNot Nothing Then
							Dim methodInfo As MethodInfo = eventInfo.GetRemoveMethod(True)
							If methodInfo IsNot Nothing Then
								methodInfo.Invoke(Nothing, {d})
							End If
						End If
					End If
				Next
			End If
		End If

	End Sub
Hope, you can fix this issue in the next version.

Thank you,

Markus

Re: Memory-Leak StiReport.Design() found (and solved)

Posted: Wed Aug 28, 2013 11:33 am
by casic
Sorry - the StiDesigner.ClosedDesigner() should be used of course...

Cu

Markus

Re: Memory-Leak StiReport.Design() found (and solved)

Posted: Thu Aug 29, 2013 9:39 am
by HighAley
Hello.

As we understand you have sold your issue, isn't it?
Let us know if you still have any problem.

Thank you.

Re: Memory-Leak StiReport.Design() found (and solved)

Posted: Thu Aug 29, 2013 9:57 am
by casic
Hi,

yes - the provided code solves the issue but it should not be neccessary to remove static event handler by reflection to close memory leaks in the report designer. I have posted the code so you can easily locate the origin of the memory leak and fix it. This would be welcome by all customers!

Thank you,

Markus

Re: Memory-Leak StiReport.Design() found (and solved)

Posted: Thu Aug 29, 2013 1:29 pm
by HighAley
Hello.

We are working in this direction.
We will let you know when this memory leak will be fixed.

Thank you.

Re: Memory-Leak StiReport.Design() found (and solved)

Posted: Thu Aug 29, 2013 1:55 pm
by casic
Great! Thank you very much!

Cu

Markus

Re: Memory-Leak StiReport.Design() found (and solved)

Posted: Fri Aug 30, 2013 5:21 am
by HighAley
Hello.

Do not hesitate to contact us in future.

Thank you.