jprajogo Posted April 4, 2017 Report Share Posted April 4, 2017 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. Quote Link to comment Share on other sites More sharing options...
JuanC Posted April 4, 2017 Report Share Posted April 4, 2017 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 Quote Link to comment Share on other sites More sharing options...
jprajogo Posted April 4, 2017 Author Report Share Posted April 4, 2017 (edited) 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 April 4, 2017 by jprajogo Further information. Quote Link to comment Share on other sites More sharing options...
JuanC Posted April 6, 2017 Report Share Posted April 6, 2017 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 Quote Link to comment Share on other sites More sharing options...
jprajogo Posted April 6, 2017 Author Report Share Posted April 6, 2017 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. Quote Link to comment Share on other sites More sharing options...
JuanC Posted April 7, 2017 Report Share Posted April 7, 2017 Yes, I was referring to the latest ChartFX 7 build. Any build marked 7.0.6305 or later should include the fix. Regards, JuanC Quote Link to comment Share on other sites More sharing options...
jprajogo Posted April 9, 2017 Author Report Share Posted April 9, 2017 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? Quote Link to comment Share on other sites More sharing options...
IGSFX Posted April 10, 2017 Report Share Posted April 10, 2017 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.