1
0

WPFのメモリリークをようやく発見した話

Posted at

アニメーションで画像を点滅させるロジックを下記のように書いていた。
まさにこの<Border.Style>から</Border.Style>までが駄目だったようでちまちまメモリリークしてた。

C#
<Border BorderBrush="Black" CornerRadius="5" BorderThickness="1" Width="64" Height="64">
    <Border.Background>
        <ImageBrush Stretch="Fill" ImageSource="{StaticResource HogePiyo}"/>
    </Border.Background>
    <Border.Style>
        <Style>
            <Style.Triggers>
                <EventTrigger RoutedEvent="Image.Loaded">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation
                                Storyboard.TargetProperty="Opacity"
                                From="1" To="0.3" Duration="0:0:3"
                                RepeatBehavior="Forever" AutoReverse="true" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Style.Triggers>
        </Style>
    </Border.Style>
</Border>

環境

.NET3.5
VisualStudio2015(2010、2022でもメモリリークしてた)

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0