Jump to content
Software FX Community
jprajogo

User handle leak calling Chart.Reset()

Recommended Posts

jprajogo    0

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.

Share this post


Link to post
Share on other sites
JuanC    0

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

Share this post


Link to post
Share on other sites
jprajogo    0

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.

Share this post


Link to post
Share on other sites
JuanC    0

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

Share this post


Link to post
Share on other sites
jprajogo    0

Thank you for the update Juan, that is very good news indeed! Just to confirm, when you say the latest build, are you referring to the latest Chart FX 7 build? In any case I will download the latest build of Chart FX 7 and give it a go. Thanks again.

Share this post


Link to post
Share on other sites
JuanC    0

Yes, I was referring to the latest ChartFX 7 build. Any build marked 7.0.6305 or later should include the fix.

Regards,

JuanC

Share this post


Link to post
Share on other sites
jprajogo    0

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? 

Share this post


Link to post
Share on other sites
IGSFX    0

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×