首页 > 解决方案 > Vue memory leak: each time v-if value is changed, more memory is needed

问题描述

I have many components X which themselves contain many more components. X all have a v-if=“show”. Show is triggered by the user for each X and can be triggered as many times as the user pleases. Now I figured that each time the user triggers “show” (twice) the application needs more memory. I don’t really understand why, because to my understanding the component X and all underlying components should be completely removed from memory as soon as “show” is false?

Can someone tell me why this might happen? Thanks!

标签: vue.jsmemory-leaks

解决方案


这实际上似乎是我的错误。我在一遍又一遍地触发组件后立即拍摄了快照。如果您等待几秒钟然后拍摄快照,Vue 会处理它并且内存恢复正常。


推荐阅读