2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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でもメモリリークしてた)

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?