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

LottieCompositionCache cache memory #2260

Closed
zijinzhiyun opened this issue Mar 8, 2023 · 7 comments
Closed

LottieCompositionCache cache memory #2260

zijinzhiyun opened this issue Mar 8, 2023 · 7 comments

Comments

@zijinzhiyun
Copy link

Lottie is supported and developed on nights and weekends. Issues from Lottie sponsors will be prioritized.

Describe alternatives you've considered
LottieCompositionCache cache 20, but the size of each LottieComposition is different.In the gift scenario, the size of LottieCompositionCache may be 50M. The number of caches is not a good solution

@gpeal
Copy link
Collaborator

gpeal commented Mar 8, 2023

@zijinzhiyun Is there an alternative you'd like to propose? What's wrong with the current implementation for your use cases? 20 refers to the number of items, not the number of mb.

@FeanCheng
Copy link

FeanCheng commented Mar 15, 2023

yep,If we know how to calculate memory size correctly,we can try to limit the memory

@FeanCheng
Copy link

In my project, a single Lottie may take up to 200Mb of memory

@FeanCheng
Copy link

Perhaps, we can manually remove the cache or disable cache

@FeanCheng
Copy link

@gpeal look here

@zijinzhiyun
Copy link
Author

@zijinzhiyun Is there an alternative you'd like to propose? What's wrong with the current implementation for your use cases? 20 refers to the number of items, not the number of mb.

Sorry, we didn't reply in time. Calculate the size of each object in the LottieComposition class, plus the memory of bitmap. In using svga libraries like lottie, I use this method. The problem with this solution is that the calculated memory value is not accurate enough. I don't know if you have a better solution.

@gpeal
Copy link
Collaborator

gpeal commented Apr 9, 2023

You can call LottieCompositionFactory.clearCache(context) if you need to clear the cache for your own app's use cases. For now, I think I'm going to leave it up to individual apps to call this unless there is a general solution that works better.

@gpeal gpeal closed this as completed Apr 9, 2023
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
@gpeal @zijinzhiyun @FeanCheng and others