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

Memory Leak #180

Open
reitowo opened this issue Nov 11, 2023 · 0 comments
Open

Memory Leak #180

reitowo opened this issue Nov 11, 2023 · 0 comments

Comments

@reitowo
Copy link

reitowo commented Nov 11, 2023

Assume this template:

<div v-auto-animate class="flex flex-column flex-grow-1"
             :style="{ gap: `${conf.style_quest_spacing / 16}rem` }">
  <StageSongItem :song="song" :config="conf" :index="index + 1" v-for="(song, index) in songs" :key="song.db_id"/>
</div>

In javascript, this triggers every second.

const getActiveSongs = async () => {
  const ret: { songs: Song[], finished: number } = (await axios.get('/api/song/active')).data
  songs.value = ret.songs
  finishedCount.value = ret.finished
}

It is observed that this function is called every time the songs.value is set
image

the forEach will setTimeout on every el children, and doesn't clearTimeout, which will create thousands of thousands closure and callbacks, and leads to memory leak.
image

This replacement of array is common in vue design.
image

So, in theory, any update frequency less than 2s will cause the memory go insane eventually. In fact the intervals is never get clearInterval either, so that is another leak point.

In conclusion, auto-animate doesn't work with changing items (for a long runtime)

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

No branches or pull requests

1 participant