Vue: Why isn't Nodes and Listener removed when switching route?

Created on 7 Jun 2017  ·  9Comments  ·  Source: vuejs/vue

Version

2.3.3

Reproduction link

https://forum.vuejs.org/t/why-isnt-nodes-and-listener-removed-when-switching-route/11637

Steps to reproduce

Destroy Vue components or Dom by a method as using vue-router or simple v-if.

What is expected?

JS Heap memories don't increase by destroying Vue components.

What is actually happening?

JS Heap memories increase when creating new Vue components.


I contributed same topic to vue's official forum but I couldn't obtain a valid answer.
So please let me question again.

VNodes and Listeners remain when Dom destroyed and JS Heap memories increase.

For more information. Please access link I posted.

Sorry for double contribution.
Please reply if you know anything.

Most helpful comment

This is out in 2.3.4

All 9 comments

I think I have the similar problem as you.
There are two pages A and B, and both listen a event through event BUS. When I switch A to B by vue-router and trigger the event, page A also response the event. As if component has been destroyed after switching router, but the listener is still there.

@Simonalia That's probably unrelated to OP's problem. You likely forgot to use $off() to unregister your Event Bus listener in the component's beforeDestroy() hook. Vue doesn'T do that for you when you use an event bus.

If you have further questions, please ask them on forum.vuejs.org. This issue here should focus on OP's problem.

Yeah, I got it. Thank you. @LinusBorg

Thanks, looks like there's indeed some memory leak going on, I've identified the source and working on a fix.

@yyx990803 Thank you very much for your help!

This is out in 2.3.4

I have same issue with 2.5.16 version.

Here example: https://jsfiddle.net/vjkosmos/hbbb28ky/

If you will fast clicking on button you can see in chrome de tools Performance monitor are not Nodes and Listener removed.

Commenting on a -year old, closed issue will hardly be noticed. Please file a real bug report.

Was this page helpful?
0 / 5 - 0 ratings