-
Notifications
You must be signed in to change notification settings - Fork 8
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
fix: 🐛 memory leak when creating LottieRenderer #102
base: main
Are you sure you want to change the base?
Conversation
|
@@ -31,10 +31,14 @@ pub struct LottieRenderer { | |||
|
|||
impl LottieRenderer { | |||
pub fn new() -> Self { | |||
let thorvg_canvas = Canvas::new(TvgEngine::TvgEngineSw, 0); | |||
let mut thorvg_canvas = Canvas::new(TvgEngine::TvgEngineSw, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can remove these dummy instances, you can set an LottieRenderer initialization flag (bool) to quickly bypass the calls for the other requested methods. The initialization toggle should be assigned within the load_data()
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, you can reuse the background and animation with calling clear(false) in the load method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion @hermet!
I was planning to reuse the same instances to avoid new mem allocation on load, i added this temp workaround for testing.
No description provided.