vuejs / core

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
https://vuejs.org/
MIT License
47.75k stars 8.35k forks source link

Memory leak with `v-if` and event #12452

Closed miroljub1995 closed 1 day ago

miroljub1995 commented 1 day ago

Vue version

3.5.13

Link to minimal reproduction

https://play.vuejs.org/#eNq1U02L2zAQ/StCFyewtUnSXlJn2XbJoYV+kC49CYprjxNt9GEk2Rsw/u8dSY2TLO0SCgUfrJnnp/dmnnv6rmnSrgW6pLktDW8cseDa5pYpLhttHOmJgZoMpDZakgShydi617KZ/W6kWTh5ruTtBWJ+gZgfEUyVWlmH7KoCc7/joiIrf9fEmRamAZFnUROqwYMD2YjCAZ4IyePl3Sterxg9I2GU3O14VYG6rCN5XQgL2M9ODPOrwHl2dje9oc6i9ppv00erFY6u93yMlkjIBZgvjePojdElCR3fK4TQTx9Dzfu7OdbLHZT7P9Qf7cHXGP1qwILpUMrYc4XZgovt9bfPcMD3sSl11QpEv9DcgNWi9Roj7H2rKpR9hgtqP4QdcrV9sOuDA2WPprxQjxwCnlHcqJ/l36yf5C7S1+E7pgac4hiY5+EjolBbXIhDHhx4zAlI7nAtFdRcwRoPNu/JBLz+uEFGp0vSaV6R4XYS81OKwtoQwk+F2YOJmqyWsClUpeX3QrSApIw+7Lgl+ISoljFHqPIUUxkJVkTB0xljuOilmFa8Cy+E9P2RZEBeX8l/ts5pRe5Kwcs9GvYeJ0m0k0zR/Aak7iAKitpmeRa/ivRZ5H8e0PFP+0+jvc7xv/ibX+XvRwfGxxHtLdI36WxBh18WKJsI

Steps to reproduce

  1. Open the reproduction link
  2. Click on Remove child from 1
  3. Find CompMarker in Memory snapshot

What is expected?

It is expected to allow for garbage collector to collect CompMarker object after v-if expression evaluates to false.

What is actually happening?

CompMarker object is found in JS heap. The weird thing is that when v-if outcome is changed to false from other component (click on Remove child from 2), the CompMarker is removed from heap.

System Info

System:
    OS: macOS 15.1.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 235.75 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.18.0 - /opt/homebrew/opt/node@20/bin/node
    npm: 10.8.2 - /opt/homebrew/opt/node@20/bin/npm
  Browsers:
    Chrome: 131.0.6778.86
    Safari: 18.1.1

Any additional comments?

No response

edison1105 commented 1 day ago

duplicate #12306