Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation type of Infinite can not dispose, Memory leak #7349

Closed
peng007ge opened this issue Jan 12, 2022 · 3 comments
Closed

Animation type of Infinite can not dispose, Memory leak #7349

peng007ge opened this issue Jan 12, 2022 · 3 comments

Comments

@peng007ge
Copy link

peng007ge commented Jan 12, 2022

Describe the bug
First,
Infinite Animation in xaml failed to release.

<Style Selector="DockPanel[IsVisible=true]">
    <Style.Animations>
	    <Animation Duration="0:0:0.8" IterationCount="Infinite" PlaybackDirection="Alternate">
		    <KeyFrame Cue="0%">
			    <Setter Property="Opacity" Value="0.2"/>
		    </KeyFrame>
		    <KeyFrame Cue="100%">
			    <Setter Property="Opacity" Value="1.0"/>
		    </KeyFrame>
	    </Animation>
    </Style.Animations>
</Style>

To Reproduce
then,I try.

       Animation animation = null;
       IDisposable subscriptions = null;
       private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (animation == null)
            {
                animation = new Animation
                {
                    Duration = TimeSpan.FromSeconds(0.8),
                    IterationCount = IterationCount.Infinite,
                    PlaybackDirection = PlaybackDirection.Alternate,
                    Children =
                    {
                        new KeyFrame
                        {
                            Cue= new Cue(0),
                            Setters=
                            {
                                new Setter(OpacityProperty,0.2)
                            }
                        },
                        new KeyFrame
                        {
                            Cue= new Cue(1.0),
                            Setters=
                            {
                                new Setter(OpacityProperty,1.0)
                            }
                        }
                    }
                };
                var rec = this.FindControl<DockPanel>("rec");
                subscriptions = animation.Apply(rec, rec.Clock, Observable.Return(true), () => { });
            }
            else
            {
                subscriptions?.Dispose();//not work
                //this is work
                animation.IterationCount = new IterationCount(0);
                animation = null;
            }
}

I hope can release Animation in xaml when my control removed.

  • OS: [Windows10]
  • Version [0.10.7]
@ds1709
Copy link

ds1709 commented Apr 27, 2024

I got same problem. I have a modal window (ShowDialog) with infinite animation. After closing whis window, animation keep working, consumming memory, CPU and GPU. Opening this window multiple times consumes more and more memory and CPU/GPU. So after some time application become unusable and must be restarted.

@peng007ge
Copy link
Author

I got same problem. I have a modal window (ShowDialog) with infinite animation. After closing whis window, animation keep working, consumming memory, CPU and GPU. Opening this window multiple times consumes more and more memory and CPU/GPU. So after some time application become unusable and must be restarted.

Probably,It it fixed on ver 11.x,I am not found the bug now

@timunie
Copy link
Contributor

timunie commented Apr 29, 2024

@peng007ge closing this as it's solved for the OP.

Note

Animations still have high memory usage, we are aware of. But it shouldn't be leaking anymore

@ds1709 let us know your version you use. If it's 11.1 beta, open a new issue with a minimum sample attached. Thx 🙏

@timunie timunie closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants