Comments (11)
What's wrong with the built-in WPF video support? (MediaElement control)
Nothing, I just didn't knew about it.
So, I just converted gifs into avi and use MediaElement, thank you.
from wpfanimatedgif.
Hi @Podpivasnique,
Sorry you're having trouble. How do you observe the memory leak? Task manager? Profiler? Does the app crash with OutOfMemoryException?
Are you able to reproduce the problem in a minimal app?
Can I somehow play gif from the end till start?
You could, using ImageAnimationController.GoToFrame
, but you would need to handle the timing yourself. There's no built-in way to play an animation in reverse.
from wpfanimatedgif.
How do you observe the memory leak?
First time I saw this in task manager. So, I took a profiler snapshots:
1 - before gif usage.
2 - first gif
3 - second gif
OutOfMemoryException
No (not yet), but it's still critical for me becasue my project in .net framework 4.0 and I need windows XP old pc's support. And for this reason I unable to use Win2D or XamlAnimatedGif.
Are you able to reproduce the problem in a minimal app?
It's already kind of a minimal app - few buttons, image control, few textblock, background and entity dbContext only once opened (and closed), nothing else.
from wpfanimatedgif.
OK, so it looks like a real leak. I'll look into it
It's already kind of a minimal app - few buttons, image control, few textblock, background and entity dbContext only once opened (and closed), nothing else.
Any chance you could share it with me (maybe without the DbContext part) so that I can reproduce the problem?
from wpfanimatedgif.
I created minimal app https://github.com/Podpivasnique/WpfAnimatedGifTestApp which represent my current project.
So, it's actually disposing, but too late. It's disposing on first gif (in new circle), on fourth gif memory leak comes to 1.4gb.
from wpfanimatedgif.
Thanks @Podpivasnique, I'm looking into it now.
So far I just looked with Task Manager; I see the memory usage go pretty high (above 1GB), but it goes down every now and then and doesn't seem to grow farther than that.
from wpfanimatedgif.
If I keep switching between images, memory usage never goes over 1.4 GB, and often falls back to 500 or 600 MB.
Using the VS memory profiler, I'm unable to identify any object that the library holds onto after unloading an image. There are a few low-level WPF internals that stay in memory for a while, but they seem to get collected after a while.
So, it uses an awful lot of memory (which is a well-known problem of this library), but I don't think there's a leak...
The fundamental problem, I think, is that your images are very large (e.g. 1.gif is 1200x700, with 29 frames), even though they are very poor quality. Keep in mind that WpfAnimatedGif holds all the decompressed frames in memory, so using such large images is bound to use a lot of RAM. In this case, you could probably make the images much smaller without losing quality, and just scale them up if you need to make them look larger. E.g. if you resize them down by a factor of 5, pixel data would use 25x less memory...
As for why the memory isn't immediately reclaimed when you GC.Collect, I suspect WPF does its own management of low-level primitives, and unfortunately there's no way to control that, as far as I can tell.
from wpfanimatedgif.
it uses an awful lot of memory (which is a well-known problem of this library)
I know.
I don't think there's a leak
I was tested that minimal app on clear virtual win xp with 1gb ram and application crashes on third gif, but the gif actually pretty similar and on first-second gif the process uses 400-500mb. That's why I wrote about too late disposing - I thot there is a way somehow align memory only for current gif.
WPF does its own management of low-level primitives, and unfortunately there's no way to control that
Eh, sounds bad man.
if you resize them down by a factor of 5, pixel data would use 25x less memory
Sounds interesting. Can you tell in more detail how can I do this (in which application)? Because I haven't really work with images/gifs. Gifs in project I was created here https://ezgif.com/ , and I have all original raw frames.
Anyway, thanks for your supporting.
from wpfanimatedgif.
Can you tell in more detail how can I do this (in which application)?
Not really... I guess there must be applications capable of resizing animated GIFs, but I don't know them.
Gifs in project I was created here https://ezgif.com/ , and I have all original raw frames.
in this case you can resize the original frames and recreate the GIFs
But I think you would get better results (in terms of performance and memory usage) with a video instead of an animated GIF
from wpfanimatedgif.
I think you would get better results (in terms of performance and memory usage) with a video instead of an animated GIF
Can you recommend .net framework 4.0 wpf video library?
from wpfanimatedgif.
Can you recommend .net framework 4.0 wpf video library?
Not really... What's wrong with the built-in WPF video support? (MediaElement
control)
from wpfanimatedgif.
Related Issues (20)
- Set from code HOT 2
- Huge memory consumption HOT 1
- Application freezes when resizing the window HOT 1
- Memory Leak HOT 3
- Version is 0.0.0.0 HOT 6
- Crash application when reading specific gif HOT 1
- error HOT 1
- When changing GIFs, the animation stops working HOT 11
- An XDG0062 error is thrown HOT 4
- Is there a way to free the BitmapImage ressources? HOT 2
- Some gif pics cannot display correctly. HOT 3
- Does not display a specific gif file HOT 3
- Not working with DrawingImage HOT 5
- File version lowered to 1.0.0 HOT 4
- Cache gif in memory so it plays instantly when shown HOT 7
- Delay animation for any gif? HOT 4
- Memory Leak HOT 3
- Pause and play with XAML HOT 1
- System.Windows.Markup.XamlParseException: Could not load 'file or assembly 'WpfAnimatedGif HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wpfanimatedgif.