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

Possible memory leak with Transition #12181

Open
miroljub1995 opened this issue Oct 15, 2024 · 4 comments · May be fixed by #12182
Open

Possible memory leak with Transition #12181

miroljub1995 opened this issue Oct 15, 2024 · 4 comments · May be fixed by #12182
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: transition

Comments

@miroljub1995
Copy link

miroljub1995 commented Oct 15, 2024

Vue version

3.5.12

Link to minimal reproduction

https://play.vuejs.org/#eNqVU9uO0zAQ/ZXBL0mlkhQKLyUtLKuVgAdAbCVeLFUhdVrvOo5lO21RlG/go/gxxnbSbREqu1JuM+d4fMZz0pIrpZJdw8iMZKbQXFkwzDZqQSWvVK0ttKBZCR2Uuq4gQmp0hK63XKx7IEl95GpFb46M7zpXiunAoSRJ+4SjUYI8KotaGtx0W+8lzN1ecZkLw0YIZmmQhGIwsKxSIrcMI4DsR2NtLeFdIXhxP6dkKPDMf1CyaNu+6FuIPvA1i2AG0S1mIui6LA3rQ61elA8wDG3tnvNyqEsJpAO65jvEGEpcZCkGocTQGEZZeqKUjIk12GLJN8mdqSWec+sWUFLUleKC6S/KcjwCSmbgEYflQtT7Tz5ndcPGQ77YsuL+H/k7c3A5Sr5qZpje4dkeMZvrDbMBvrn9zA74fQSret0IZF8AvzFTi8ZpDLT3jVyj7BOeV/vRD5zLzdLcHCyTZmjKCXXMzvMpwclfX2j9Qe40eeXXUdnhKR7d9Uin+o0oeXCYZfgIBpNsD1da5z/j6WQ1mfh7lJRciBjfVa7ieDUGPoL5AuIWOHSj0X/8GIyxWG65AbwKpxa7av22iWByY7fed8Exf3vk5Ld4en+XfpOlznEU7pjP/eu97UdDegAhI2qLpvavnn3i8LNSZw38/oUtrHZMu6Gj/mnyOnnxknR/AOXRc60=

Steps to reproduce

Open Memory tab in dev tools and just click Show and Hide multiple times.

What is expected?

After Hide and Collect Gargabe memory should be reclaimed to around 100MB.

What is actually happening?

Memory allocation is continuously increasing without any notable decrease after Hide and Collect Gargabe.
If I remove Transition, everything works okay.

System Info

System:
    OS: macOS 15.0.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 1.36 GB / 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: 129.0.6668.91
    Safari: 18.0.1

Any additional comments?

No response

@edison1105
Copy link
Member

The current usage is not reasonable because the <div> inside the <Transition> does not undergo any insertions or removals, thus the transition animation will not be triggered. This scenario can be considered an edge case.

@edison1105 edison1105 added 🔩 p2-edge-case 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. and removed 🔩 p2-edge-case labels Oct 15, 2024
@edison1105
Copy link
Member

@ferferga
Thank you for providing the demo. I acknowledge that there is a memory issue present. However, it is important to note that the memory usage and detached DOM nodes do not continuously grow and eventually stabilize. Therefore, it does not strictly qualify as a memory leak.

fixed via ec2fcec
Please feel free to review.

@ferferga
Copy link
Contributor

@edison1105 Thank you very much as always!

That commit does indeed fix the issue if I introduce a copy of ChildEmpty at the end of the toggling cycle.

However, even if it's not technically a leak as you mention, it's (in my opinion) not an efficient usage of resources either and a behaviour people would expect to belong to KeepAlive. Not sure if there's a known room for improvement here but you just tried to fix the leak or you're not sure how to properly improve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: transition
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants