Jump to content
Software FX Community

User handle leak calling Chart.Reset()


jprajogo

Recommended Posts

We have a form which hosts the Winforms.Chart control, and as part of its initialization process, we call Chart.Reset(). This call appears to leak a user handle object. This problem has become much more of an issue recently as we have a client with a process which renders n instances of the chart as part of a collection in a loop. As such the leak is much more noticeable, and the more instances to render, you would eventually get to a point where these resources have been exhausted and the only way to get past the issue is to restart the application. Has anyone seen this issue and/or know of it or have any suggestions? Any help or suggestions would be very much appreciated and thank you in advance.

Note: we are using ChartFx.WinForms version 7.0.3306.26568.

Link to comment
Share on other sites

Please note that Chart.Reset is meant to be used if you have a "dirty" chart that you need to reset to its original state, e.g. a chart with data and several settings that you need to reset back. You mentioned you are doing this as part of the initialization process so I wonder why you are using Reset.

The code for reset reinitializes the chart using our serialization process but does not show an obvious leak, can you clarify how are you detecting this leak?

Regards,

JuanC

Link to comment
Share on other sites

Yes, that is correct. In this 'rendering loop' we recycle our control for performance reasons before rendering the next item on the list. So we need to reset the chart to the original state before continuing. 

In our 'loop' we call a Render method - and I have wrapped this call with a call to GetGuiResources through pinvoke. like so:

Debug.WriteLine(string.Format("User Handle count before Render: {0}", GetUserObjectCount().ToString()));
renderer.Render(this, control, this.resultStream);
Debug.WriteLine(string.Format("User Handle count after Render: {0}", GetUserObjectCount().ToString()));

where GetUserObjectCount is defined as such:

private int GetUserObjectCount()
{
	return Convert.ToInt32(GetGuiResources(Process.GetCurrentProcess().Handle, GR_USEROBJECTS));
}

private const uint GR_USEROBJECTS = 1;

[DllImport("User32.dll")]
static extern uint GetGuiResources(IntPtr hProcess, uint uiFlags);

Here I can clearly see that the delta between before and after is 1 (increasing). Stepping through the 'Render' code reveal the increase in count specifically when calling:

m_chart.Reset();

where m_chart is a WinForms.Chart object, and I can verify this further by wrapping this line with the same call to GetGuiResources.

In fact, if I specifically remove the call to reset the chart above, then the leak disappears. However doing so affects our performance so we need to have the reset there.

Edited by jprajogo
Further information.
Link to comment
Share on other sites

We were failing to dispose a child control, this has been fixed on our latest build, note that this control AFAIK would still be properly disposed in the next GC but clearly if you run multiple Reset calls in a tight loop it might cause some problems.

Regards,

JuanC

Link to comment
Share on other sites

Thank you Juan, is there a link we can access to view the release notes for that build? Also, the latest builds we can see appear to be version 7.0.4962 on the Software FX website; but having said that, it looks like our subscription has expired so could that be the reason? 

Link to comment
Share on other sites

Hello, the support website contains the latest released service pack. However, this fix was included in a special hotfix we created last week. In order to get this hotfix, please contact tech support at http://www.mysoftwarefx.com/support using a current support subscription. If your subscription is expired, you can renew it by contacting sales at softwarefx dot com.

IG
SFX

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...