-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
KeepAlive + Transition + v-if 同时使用时会导致时会导致内存泄漏的2个bug #10620
Comments
@wcldyx 这是因为在开发环境会在元素上定义 core/packages/runtime-core/src/renderer.ts Lines 697 to 706 in 3bf34b7
|
6啊,你是怎么定位到这个问题的 |
@wcldyx |
Leave it open because the second issue has not been fixed |
revert vuejs#10632 re-fix vuejs#10620 close vuejs#10827
Vue version
3.4.21
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-futfv6?file=src%2FApp.vue
Steps to reproduce
测试的时候注意自己创建一个新项目测试,因为stackblitz上看内存占用不方便
有两个bug
第一个bug: KeepAlive + Transition + v-if 同时使用时会导致时会导致内存泄漏。
如图所示,通过点击toggle按钮用v-if 不停的切换显示隐藏组件,你会看到内存一直没有被释放。
单独使用KeepAlive 时在通过v-if隐藏组件时内存会自动释放。
第二个bug: 在 mode="out-in"时通过v-if切换并同时移除include里面的key时,对应的组件没有被正常卸载(没有触发onUnmounted), 内存也没有得到释放。
mode为默认值时,组件能正常卸载
mode="out-in" 时,组件没有被正常卸载
What is expected?
修复以上bug
What is actually happening?
KeepAlive + Transition + v-if 同时使用时会导致时会导致内存泄漏,同时在 Transition 的 mode="out-in"时,组件没有被正常卸载或销毁
System Info
No response
Any additional comments?
No response
以下是完整代码
The text was updated successfully, but these errors were encountered: