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

Stimulsoft Reports.NET discussion
Post Reply
casic
Posts: 68
Joined: Thu Jan 18, 2007 4:25 pm
Location: Germany

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

Post 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
casic
Posts: 68
Joined: Thu Jan 18, 2007 4:25 pm
Location: Germany

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

Post by casic »

Sorry - the StiDesigner.ClosedDesigner() should be used of course...

Cu

Markus
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

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

Post 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.
casic
Posts: 68
Joined: Thu Jan 18, 2007 4:25 pm
Location: Germany

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

Post 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
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

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

Post by HighAley »

Hello.

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

Thank you.
casic
Posts: 68
Joined: Thu Jan 18, 2007 4:25 pm
Location: Germany

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

Post by casic »

Great! Thank you very much!

Cu

Markus
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

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

Post by HighAley »

Hello.

Do not hesitate to contact us in future.

Thank you.
Post Reply