I've recently purchased MemProfiler 3.0 but even after completing the tutorial I a having difficulty identifying and finding leaks in my aplication.
The App has been built over the last 2 years so its fairly larger and uses a few 3rd party .net controls.
I've got my head (I think around the real-time view and comparing snapshots) however I am unsure what I am looking for.
In the real time I let the app run and watch the Total instances and live instances. I leave it in a state that should have flat memory usage.
Take 1 snapshot .. wait some time then take the second and so on.
In the types view filtered by 'new or removed instances' I have some 150-200 entries ... nearly all system.xxx .. 1 or 2 I recognise as something I've coded. below is an example:
System.Drawing.Drawing2D GraphicsPath 1877 1447 1459 -12 0 0 0 0 570508 115478
(sorry that didn't paste well)
nearly all the instances have 1000's of undisposed instances (total) the help file says ideally these should be 0 .. so are these all leaks?
Next when I click on an instance I go to the type details path .. I get a call stack trace like such:
if..ctor(IHitTestTarget, IColorable, g4, hv, fv)
if..ctor(IHitTestTarget, IColorable, g4, hv)
if..ctor(IHitTestTarget, IColorable, g4)
h5.a(am, gj, cc)
Control.PaintWithErrorHandling(PaintEventArgs, short, bool)
NativeWindow.Callback(IntPtr, int, IntPtr, IntPtr)
[Unmanaged to managed transition]
[Managed to unmanaged transition]
Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int, int, int)
Now Program.Main() is the only thing I can click on. There is a mention of BaseGauge which is probably a reference to a 3rd party .net gauge control .. but there are quite a lot of gauges used in this application .. and of cause they are ALL below Program.Main .. how do I narrow down the search to find exactly where in the code this instance is getting created each time.
so in summary what do I look for to identify a leak, and how do I drill down to find it in my code.
I hope my ramblings make some sense and you can guide me a little on how to use this tool.
However, you do have a substantial amount of undisposed instances of the GraphicsPath. A GraphicsPath wraps an unmanaged GDI+ resource, which could potentially consume a significant amount of unmanaged memory. The managed data of the GraphicsPath only occupies 4 bytes (or 8 bytes on 64-bit OS), so the managed memory pressure will be very low for the GraphicsPath instances (and any other GDI+ instances). The GraphicsPaths are released by the finalizer, but since the managed memory pressure is low it might take a while for a GC to kick in.
The recommendation is of course to make sure that the GraphicsPath instances are correctly disposed. Unfortunately this is not something that you will be able to correct yourself, since the GraphicsPaths are created by your 3rd part gauge library (the allocation stack shows that the GraphicsPath is created in the OnPaint event of BaseGauge, via a lot of obfuscated methods).
If you believe that this causes a problem with your application, you might want to mention this to the makers of the Gauge control.
SciTech Software AB
Users browsing this forum: No registered users and 15 guests