Large memory leaks.
See original GitHub issueDescribe the bug
Hey! Been using anime in A-Frame, an open source WebVR framework. Love it. Though there is a lot of memory leak that can lead to GC pauses.
Taken from a few seconds from the anime homepage, it’s allocated hundreds of kilobytes of memory garbage.
This issue can be alleviated for free with these practices:
- Cache regexes (https://github.com/juliangarnier/anime/blob/master/src/index.js#L69 https://github.com/juliangarnier/anime/blob/master/src/index.js#L358) rather than allocating new one each call
- Use for loops rather than
Array.forEach
which allocates an entire function (https://github.com/juliangarnier/anime/blob/master/src/index.js#L779) - Try to avoid array helpers such as
Array.map
andArray.filter
andArray.reduce
andObject.keys
as these will allocate a new array (https://github.com/juliangarnier/anime/blob/master/src/index.js#L1209 https://github.com/juliangarnier/anime/blob/master/src/index.js#L321). - Avoid allocating arrays in critical codepaths, reusing a helper / auxiliary array when possible. A single array can be reused by clearing the length
array.length = 0;
(https://github.com/juliangarnier/anime/blob/master/src/index.js#L959 https://github.com/juliangarnier/anime/blob/master/src/index.js#L308) - Try to avoid cloning objects (https://github.com/juliangarnier/anime/blob/master/src/index.js#L337)
This is something I could try to help out with.
To Reproduce Steps to reproduce the behavior:
- Go to anime homepage (or any anime animation).
- Open devtools memory / performance.
- Record memory.
Expected behavior Little memory garbage / allocations.
Desktop (please complete the following information):
- OS: macOS
- Browser firefox
Issue Analytics
- State:
- Created 5 years ago
- Reactions:21
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Memory leak - Wikipedia
In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in...
Read more >How do I check for memory leaks, and what should I do ...
This is known as a memory leak, and it happens when software fails to manage the available RAM correctly.
Read more >Java Memory Leaks: Solutions, Tools, Tutorials & More - Stackify
We put together this guide to help you understand how, why, and where Java memory leaks happen – and what you can do...
Read more >Understanding Memory Leaks in Java - Baeldung
A Memory Leak is a situation where there are objects present in the heap that are no longer used, but the garbage collector...
Read more >What is Memory Leak? How can we avoid? - GeeksforGeeks
Memory leak occurs when programmers create a memory in heap and forget to delete it. The consequences of memory leak is that it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe this issue should be constrained to memory leaks versus unit testing, linting, and Typescript.
Alright, I’m going to focus on this for 3.1. I created a branch called memory plumbing, any help on this is welcome! Thanks !