Skip to content

Memory Leak #180

Open

Description

@reitowo

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions