Skip to content

Memory leak / component v-if ? #7448

@michelvermeulen

Description

@michelvermeulen

Vue version

3.2.45

Link to minimal reproduction

https://sfc.vuejs.org/#eNqdVE2P2jAQ/StWVGlBgniXthcKiFba2/bW3nIJyWQ33cS2bCe7CPHf++wkEMKC0OYQzXjefHjmjXfBT6XCuqJgHixMonNlV5HISyW1ZX/izQPLtCxZFITcaQ4ZBT/6iNkJYjZE7JimbMKk+C0rYSll+w7fAendA1PK4qqAQyQYSyS8BQlr5s0B88VMDuLMi3v/N2QrNRp3wEQKY5l5kW++/qUrYGR1RWMkcwANvBYdHP4ttI2+9zAX2kkLfugKFEulKmJL0BhbpHntBYg+1VoqEq64ZRT08mdxYXBVVk/zrGfBCe+5z9h6Eyevp66ubO9JCNHCF7zJu+C9aqAauy2ImQRFpCuU7VRYgknQjGJaxir8Z6TAqP3do9ZgouDQ5XYscwgv1ioz57wS6vU5xET4GjauMca8pGkqy/XXcBZ++456jO2fh2TK6UbLN0MaGaOg7awPznFYk55qEilp0leTDbAnCQe2s6R+ihgiGtAR05H8fISwXuzpYCN2RyI7Tv+iTGr6K0p3dBuzG7IqLZWZIByVORwH3H2lbSrfBOY/ojFbro5UzTMchbCz5RKJHk0SK+Q6+LvPhRxFgSMTLC3nfSuO7GbHe4ywOf0UqUyqEpsXxmn6WEN4QrNJkEbMtjAMtKuxi7/vhEFTLkbXVMqaPpGg295ra9qsQhGLZ7dOiQEbPlyM7kn7mBftbuZCVdY9IojlZQSzW0VQLb07La6szHAxc1zoTWWtFFhc9ML5sVywh/v7e6DXSZH7Pf/iJ3XXPRp34yhYPeWCFrzxvr7t15iJYs/ZeI2PAwI2V25eTlEVxXG4F0jDuXcJ67ioKPS9GF2c3IHMzuWGR/e2ae7/A16gPXA=

Steps to reproduce

  • Create a new project
  • Alternate 2 components with v-if
  • Add an input and focus on the mounted hook on one of the components
  • Toggle between components, force the GC in Chrome Devtools each time you switch components

What is expected?

  • The components and listeners should be GC and the memory should go back to initial level

What is actually happening?

  • The number of listeners and components keeps growing and the memory heap as well

System Info

No response

Any additional comments?

I've been scratching my head for days now. I have a similar issue in my app, and it looks like it doesn't happen if I don't add the focus to the field in the mounted hook.

Problem seems systematic on Vue SFC, and it also happens, although not as consistently, on my test app:

https://we.tl/t-yXD6l3kVxm

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