Trouble Profiling WPF application

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
AlanREI
Posts: 3
Joined: Tue Dec 10, 2013 9:11 pm

Trouble Profiling WPF application

Post by AlanREI » Tue Dec 10, 2013 9:14 pm

I get tons of "issues" when profiling my WPF application that shouldn't be real issues. Is it actually possible to profile a WPF application without getting spammed by tons of these?

All of these issues appear after opening an image then closing it - once .

Code: Select all

Direct EventHandler roots (Show details) (Ignore...)
6 types have instances that are directly rooted by an EventHandler. This can indicate that an EventHandler has not been properly removed.
Investigate the types below for more information.

ContentControlRegionAdapter.<>c__DisplayClass2, DataBindEngine.DataBindEngineShutDownListener, WeakEventTable.WeakEventTableShutDownListener, ManagedWndProcTracker.ManagedWndProcTrackerShutDownListener, WindowSettings, TextServicesContext.TextServicesContextShutDownListener

Disposed instances (Show details) (Ignore...)
10 types have instances that have been disposed but not GCed. 
Investigate the types below for more information.

PropertyPathWorker.ContextHelper, ObservableCollection<DockingWindow>.SimpleMonitor, ObservableCollection<DocumentWindow>.SimpleMonitor, ObservableCollection<GroupDescription>.SimpleMonitor, ObservableCollection<ItemMetadata>.SimpleMonitor, ObservableCollection<object>.SimpleMonitor, ObservableCollection<ResourceDictionary>.SimpleMonitor, ObservableCollection<string>.SimpleMonitor, UnmanagedMemoryStream, WriterDelegate

Undisposed instances (release resource) (Show details) (Ignore...)
5 types have instances that have been garbage collected without being properly disposed. 
Investigate the types below for more information.

SafeFileHandle, SafeWaitHandle, BitmapSourceSafeMILHandle, SafeMILHandle, SafeProfileHandle

Direct delegate roots (Show details) (Ignore...)
4 types have instances that are directly rooted by a delegate. This can indicate that the delegate has not been properly removed.
Investigate the types below for more information.

DelegateCommand.<>c__DisplayClass6, SpectrumPCBootstrapper, System.__Filters, __Filters

Pinned instances (Show details) (Ignore...)
2 types have instances that are pinned in memory. 
Investigate the types below for more information.

System.Object, System.Object[]

Indirect EventHandler roots (Show details) (Ignore...)
22 types have instances that are indirectly rooted by an EventHandler. This can indicate that the EventHandler has not been properly removed.
Investigate the types below for more information.

<GCHandle>, WINDOWPLACEMENT, WindowSettings.WindowApplicationSettings, ArrayList, Hashtable, Hashtable.bucket[], Hashtable.ValueCollection, ClientSettingsStore, LocalFileSettingsProvider, SettingsAttributeDictionary, (...)

Indirect delegate roots (Show details) (Ignore...)
2 types have instances that are indirectly rooted by a delegate. This can indicate that the delegate has not been properly removed.
Investigate the types below for more information.

System.Action, System.Func<bool>

Undisposed instances (perform action) (Show details) (Ignore...)
2 types have instances that have been garbage collected without being properly disposed. 
Investigate the types below for more information.

System.IO.FileStream, System.Net.FileWebStream

Undisposed instances (memory/resource utilization) (Show details) (Ignore...)
7 types have instances that have been garbage collected without being properly disposed. 
Investigate the types below for more information.

BamlStream, System.IO.BinaryReader, UnmanagedMemoryStream, ResourceReader, RuntimeResourceSet, ManualResetEvent, BamlBinaryReader (inherited)

Duplicate instances (Show details) (Ignore...)
366 types have duplicate instances (5,674 sets, 1,608,309 duplicated bytes). Duplicate instances can cause unnecessary memory consumption.
Investigate the types below for more information.

System.String (2,049 sets, 447,952 duplicated bytes), List<XamlNode> (896 sets, 219,152 duplicated bytes), WriterDelegate (32 sets, 218,294 duplicated bytes), ResourceDictionary (4 sets, 124,698 duplicated bytes), Baml2006SchemaContext.BamlProperty (429 sets, 94,488 duplicated bytes), Baml2006SchemaContext.BamlAssembly (11 sets, 75,218 duplicated bytes), Baml2006SchemaContext (7 sets, 65,358 duplicated bytes), Baml2006Reader (4 sets, 64,370 duplicated bytes), List<Baml2006SchemaContext.BamlAssembly> (6 sets, 59,928 duplicated bytes), System.Byte[] (48 sets, 51,908 duplicated bytes), (...)

Instances queued for finalization (pending finalizer) (Show details) (Ignore...)
3 types have instances that are queued for finalization. 
Investigate the types below for more information.

GCNotificationToken, GCNotificationToken, GCNotificationToken

Empty weak reference (Show details) (Ignore...)
The WeakReference type has instances that are no longer alive.
Investigate the WeakReference type for more information.

System.WeakReference

Large instances (Show details) (Ignore...)
2 types have instances that are located in the large object heap. 
Investigate the types below for more information.

System.Byte[], System.Object[]

FixedAddressValueType instances (Show details) (Ignore...)
114 types have instances that are pinned in memory by the FixedAddressValueType attribute. 
Investigate the types below for more information.

__type_info_node, $ArrayType$$$BY09UCONTROL_TABLE@TtfDelta@Internal@MS@@, BASEAXIS_CONTROL$$BY0A@E, BASECOORDFORMAT2_CONTROL$$BY0A@E, BASEFEATMINMAXRECORD_CONTROL$$BY0A@E, BASEHEADER_CONTROL$$BY0A@E, BASELANGSYSRECORD_CONTROL$$BY0A@E, BASEMINMAX_CONTROL$$BY0A@E, BASESCRIPT_CONTROL$$BY0A@E, BASESCRIPTLIST_CONTROL$$BY0A@E, (...)

Undisposed instances (unclassified) (Show details) (Ignore...)
11 types have instances that have been garbage collected without being properly disposed. 
Investigate the types below for more information.

ObservableCollection<DockingWindow>.SimpleMonitor, ObservableCollection<GroupStyle>.SimpleMonitor, ObservableCollection<object>.SimpleMonitor, ExecutionContext, Task<object>, Baml2006Reader, DeferringWriter, ReaderDelegate, ReaderMultiIndexDelegate, WriterDelegate, (...)

Undisposed instances (no action) (Show details) (Ignore...)
3 types have instances that have been garbage collected without being properly disposed. 
Investigate the types below for more information.

FileWebResponse, CollectionView.SimpleMonitor, HitTestWithPointDrawingContextWalker

Held duplicate instances (Show details) (Ignore...)
173 types have duplicate instances that are held by other duplicate instances (3,905 sets, 821,393 duplicated bytes).
Investigate the types below for more information.

XamlNodeAddDelegate (43 sets, 257,498 duplicated bytes), XamlLineInfoAddDelegate (43 sets, 257,498 duplicated bytes), System.Xaml.XamlNode[] (909 sets, 200,290 duplicated bytes), System.String (1,049 sets, 163,932 duplicated bytes), System.Object[] (63 sets, 151,796 duplicated bytes), List<object> (42 sets, 148,494 duplicated bytes), Baml2006ReaderContext (10 sets, 139,568 duplicated bytes), List<KeyRecord> (10 sets, 132,626 duplicated bytes), KeyRecord[] (10 sets, 132,530 duplicated bytes), NameScopeDictionary (8 sets, 129,878 duplicated bytes), (...)
It is extremely frustrating digging through all of these issues and new instances that appear to be by design of WPF? How can I possibly tell what is actually a problem or not?

Andreas Suurkuusk
Posts: 1005
Joined: Wed Mar 02, 2005 7:53 pm

Re: Trouble Profiling WPF application

Post by Andreas Suurkuusk » Wed Dec 11, 2013 9:16 pm

The profiler is supposed to automatically ignore several WPF related issues that aren't "real" issues. However, it seems like the currently released version of .NET Memory Profiler is not correctly ignoring these issues.

We have now corrected this, and there's a maintenance release available from http://cdn.memprofiler.com/download/Mem ... 4_6_62.exe. It has not yet been officially released, but can you download this version and see if it works better?

Framework issues are classified as "not really an issue" and "issue that is caused by the framework. The "not really an issue" issues are always ignored. To ignore all framework issues, use the command "Profiler->Ignore framework issues".

There will still be framework issues left (including WPF issues), but there should be significantly fewer. We will look into this further and improve the detection of real and false issues in future releases.
Best regards,

Andreas Suurkuusk
SciTech Software AB

AlanREI
Posts: 3
Joined: Tue Dec 10, 2013 9:11 pm

Re: Trouble Profiling WPF application

Post by AlanREI » Thu Dec 12, 2013 7:05 pm

Umm, it said my subscription is now expired when I installed that.

I tried moving on by selecting evaluate. When I got to "ignore framework issues" it was grayed out and I couldn't click on it. I'm starting my application by choosing "profiler -> debug with profiler".

edit:

Well actually it is available before I take a screen shot then it grays out. But then I clicked it on the toolbar and it now appears available again. I'm not sure what is going on there, but it didn't seem to make a difference.

What is the process I should use?

1. Profiler -> Debug with profiler
2. Ignore framework issues menu option
3. Open/close something
4. capture baseline snapshot
5. repeat #3
6. capture snapshot
7. compare

That's what I'm trying to do...

AlanREI
Posts: 3
Joined: Tue Dec 10, 2013 9:11 pm

Re: Trouble Profiling WPF application

Post by AlanREI » Thu Dec 12, 2013 7:21 pm

Also, explain to me how there are issues when I capture multiple screenshots without executing anything new in my application. Shouldn't that all be 0, shouldn't the overview be blank? I selected "With additional instances (Delta > 0)"

My application is idle and I'm taking consecutive snapshots.

Andreas Suurkuusk
Posts: 1005
Joined: Wed Mar 02, 2005 7:53 pm

Re: Trouble Profiling WPF application

Post by Andreas Suurkuusk » Fri Dec 13, 2013 1:12 pm

The "Ignore framework issues" command should be enabled whenever the profiling document window is active. I did some tests with debug profiling and noticed that it could occur that the profiling commands are not correctly enabled. We will look into this and fix it as soon as possible. In the meantime, you can force a command update by selecting a new tab in the profiling window.

The automatic memory analyzer currently only analyses the selected snapshot, and is not affected by the comparison snapshot. Therefore you will still see reported issues when you collect consecutive snapshots.

I think that is it common that you would like to see all issues in a snapshot, but there are definitely cases when you just want to see new issues between the selected snapshot and the comparison snapshot. We have started to work on a new option that gives you the possibility to only show new issues. Hopefully we can make a maintenance release available by next week that includes this possibility.

The process you use seems fine with me. You can enable/disable the "ignore framework issues" whenever you want; each change will trigger a new memory analysis.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 6 guests