Filter our leaks of .Net Framework Code

I have a super simple C# WPF sample project to learn how to use dotMemory. The project has a startup Window with just one button. The Click of the button shows the window below. If I open and close the window a couple of times dotMemory shows me some leaks. Are these bugs in the .net Framework? And if yes, can I filter them out somehow so I see only the problems in my code?

 

This is the first leak it shows:

Event handlers leak inspection

Type: TextEditor+TextEditorShutDownListener
Retained Size: 864
Count: 24

 

Here ist the XAML of the Window:

<Window x:Class="WpfMemoryProfilingTester.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfMemoryProfilingTester"
        mc:Ignorable="d"
        WindowStartupLocation="CenterScreen"
        Title="MainWindow" Height="850" Width="1525" d:DataContext="{d:DesignInstance local:MainWindowViewModel}">
    <Window.Resources>
        <DataTemplate x:Key="ItemTemplate">
            <Grid d:DataContext="{d:DesignInstance local:ItemViewModel}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="200" />
                    <ColumnDefinition Width="200" />
                </Grid.ColumnDefinitions>

                <TextBox Grid.Column="0" Text="{Binding Name}" />
                <TextBox Grid.Column="1" Text="{Binding Telefon}" />
            </Grid>
        </DataTemplate>
    </Window.Resources>
    <Grid Margin="20">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <ComboBox Grid.Row="0" ItemsSource="{Binding SelectItems}" />
        
        <ListBox x:Name="ListBox" Grid.Row="1" ItemsSource="{Binding Items}" ItemTemplate="{StaticResource ItemTemplate}" />
    </Grid>
</Window>

Attached Uploaded File: WpfMemoryProfilingTester.zip (Contains the Sample App Project)

7 comments
Comment actions Permalink

Hello Markus,

I can't see attached file here, probably it too large to upload.

Could you please upload your sample to our FTP server: ftp://ftp.intellij.net/.uploads/ 

 

0
Comment actions Permalink

Hallo Anna, I uploaded it via ftp. Name: WpfMemoryProfilingTester.zip (175 KB)

0
Comment actions Permalink

Yes, some .NET Framework assemblies can contain "Event handler" leaks. TextEditor+TextEditorShutDownListener contains in PresentationFramework assembly and you can't fix the leak in this case.

"Event handlers leak" inspection shows you a possible issues in your code which can cause a great memory usage. But you do not need to fix all of them if they do not expend a lot of memory.

0
Comment actions Permalink

About filtering: you can open "Group by assembly" view, select your assemblies and open them in separate object set which will contain types from your code.

0
Comment actions Permalink

Hello Anna, thanks for the quick answer! Just one question: Can I filter out those errors somehow in dotMemory? (I have the job during the next weeks to find memory issuses in a quite big Application and it would be fine to filter out those .Net issues there...)

0
Comment actions Permalink

Markus,

Currently, dotMemory doesn't contain special functionality to filter system types, but you can use the way which I have described above.

We have a feature request: https://youtrack.jetbrains.com/issue/DMRY-4160

You're welcome to vote for it.

0
Comment actions Permalink

Klicking on the Link for Eventhandler Issues on the snapshot view to show all items and than filter by namespace is fine...Thanks - good idea!

Filtering system types would not help here, because I use third party controls like Telerik and they also have issues... (And if I click the link to the feature request it shows me "Access denied")

Thank you for your very quick help!!!

0

Please sign in to leave a comment.