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

fix: 🐛 memory leak when LottieRenderer is created #282

Merged
merged 3 commits into from
Jan 13, 2025
Merged

Conversation

theashraf
Copy link
Member

@theashraf theashraf commented Jan 11, 2025

Context:
The background shape is destroyed only when it is owned by the canvas and the canvas is cleared or destroyed

Leaks report:

Process:         demo-player [20165]
Path:            /Users/USER/*/demo-player
Load Address:    0x1029d8000
Identifier:      demo-player
Version:         0
Code Type:       ARM64
Platform:        macOS
Parent Process:  leaks [20164]

Date/Time:       2025-01-11 22:59:19.593 +0700
Launch Time:     2025-01-11 22:59:06.200 +0700
OS Version:      macOS 14.5 (23F79)
Report Version:  7
Analysis Tool:   /Applications/Xcode.app/Contents/Developer/usr/bin/leaks
Analysis Tool Version:  Xcode 16.2 (16C5032a)

Physical footprint:         19.4M
Physical footprint (peak):  36.2M
Idle exit:                  untracked
----

leaks Report Version: 4.0, multi-line stacks
Process 20165: 196 nodes malloced for 15 KB
Process 20165: 3 leaks for 288 total leaked bytes.

STACK OF 1 INSTANCE OF 'ROOT CYCLE: <tvg::Shape>':
17  dyld                                  0x1925220e0 start + 2360
16  demo-player                           0x1029daaa4 main + 36
15  demo-player                           0x1029daca0 std::rt::lang_start::h75a238737c88dd58 + 84  rt.rs:194
14  demo-player                           0x102ae1770 std::rt::lang_start_internal::hacda2dedffd2edb4 + 1092
13  demo-player                           0x1029dacd4 std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::hc2f6f33d619d76e3 + 28  rt.rs:195
12  demo-player                           0x1029db1c0 std::sys::backtrace::__rust_begin_short_backtrace::h8cba6c8ea14dda1e + 24  backtrace.rs:160
11  demo-player                           0x1029daae8 core::ops::function::FnOnce::call_once::h1d8b2a493de320fa + 20  function.rs:250
10  demo-player                           0x1029da374 demo_player::main::h313c68b1f303524b + 40  main.rs:8
9   demo-player                           0x102a1cb44 dotlottie_rs::dotlottie_player::DotLottiePlayer::new::hde37addf97951b61 + 32
8   demo-player                           0x102a1a844 dotlottie_rs::dotlottie_player::DotLottiePlayerContainer::new::h9d6de976900f60e3 + 36
7   demo-player                           0x102a18514 dotlottie_rs::dotlottie_player::DotLottieRuntime::new::h5352e0300c55ee1a + 132
6   demo-player                           0x1029db2c4 dotlottie_rs::dotlottie_player::DotLottieRuntime::with_renderer::h7791b0e8b5bf6c54 + 180
5   demo-player                           0x102a50e8c _$LT$dyn$u20$dotlottie_rs..lottie_renderer..LottieRenderer$GT$::new::h150b8af904f5c722 + 128
4   demo-player                           0x1029f9a30 _$LT$dotlottie_rs..lottie_renderer..thorvg..TvgShape$u20$as$u20$core..default..Default$GT$::default::hfca35332b0732286 + 12
3   demo-player                           0x102ba0774 tvg_shape_new + 20  tvgCapi.cpp:273
2   demo-player                           0x102b096fc tvg::Shape::gen() + 24  tvgShape.cpp:48
1   libc++abi.dylib                       0x192863bd4 operator new(unsigned long) + 32
0   libsystem_malloc.dylib                0x1926e4a68 _malloc_zone_malloc_instrumented_or_legacy + 148 
====
    3 (288 bytes) ROOT CYCLE: <tvg::Shape 0x14b8042d0> [48]
       1 (144 bytes) ROOT CYCLE: <malloc in tvg::Paint::Paint() 0x14b804300> [144]
          CYCLE BACK TO <tvg::Shape 0x14b8042d0> [48]
       1 (96 bytes) ROOT CYCLE: <malloc in tvg::Shape::gen() 0x14b804390> [96]
          CYCLE BACK TO <tvg::Shape 0x14b8042d0> [48]

Copy link

changeset-bot bot commented Jan 11, 2025

⚠️ No Changeset found

Latest commit: 5f0d0cd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Add a new file, launch.json, to configure the debugging settings for the demo-player. This file includes the necessary attributes for launching the demo-player with the lldb debugger. The configurations include the program path, arguments, and working directory.
@theashraf theashraf marked this pull request as ready for review January 13, 2025 03:44
@theashraf theashraf merged commit c5fa543 into main Jan 13, 2025
1 check passed
@github-actions github-actions bot mentioned this pull request Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants