Closed maxneuvians closed 7 years ago
It may not be specific to f7-router events. In my application I changed some components to trigger their existence based on v-if
statements. When v-if
switched back to false the destroyed()
callback was invoked but the VueComponents were still in the memory heap. I made sure they did not have any external DOM listeners attached. I will try to reproduce this one in a simpler repo a well.
Same for me. The problem is, if there is a div with an ID on it, you have it multiple times. I have had some issues out of that behavior.
What I tried to solve that situation - add the following configuration parameters at init:
But same behavior ...
Linked to https://github.com/framework7io/Framework7-Vue/issues/197 as well, where you can find a workaround for specific cases.
These bugs affect the actual DOM items and they do get removed from the DOM - they don't get removed from the memory heap though.
Any updates on this?
Hi,
I have created a sample repo:
https://github.com/maxneuvians/vueF7MemoryLeakExample
It illustrates the issue very nicely. You create a component using a v-if
toggle which has a lot of data. In this case 100 item list. You toggle it on and off repeatedly. The destroyed
callback is invoked, but the VueComponents
are not cleared from memory.
After 18 toggles I went from 20 MB heap size to 145 MB heap size.
I tried this in plain F7Vue without webpack and it did not happen there - no VueComponents
were created.
@scriptPilot I sat with @maxneuvians today and saw the problem first hand.
@maxneuvians so the problem is in webpack?
I currently can’t check it as I’m on vacation, but if you use some custom list component or just plain <ul><li>
instead of f7-list and f7-list-item, problem still exist?
@nolimits4web I could not replicate it in https://github.com/nolimits4web/Framework7-Vue-Simple-Template with the exact same component set up. I replaced the f7-list
with ul
and f7-list-item
with li
and it did not cause a problem. However, if I do:
<div>
<f7-button v-for="number in data" :text="number"></f7-button>
</div>
It will still retain the components. So this is not specific to just <f7-list>
@nolimits4web using @maxneuvians example I can reproduce the issue with all of our phonegap-template-vue-f7-* templates that use webpack.
Well ok, so how to unload component from browser memory? As far as I know browsers don’t really allow to control memory. Maybe problem related to Vue, such v-if thing is controlled by Vue, F7 doesn’t do anything with it. Events attaching/detaching is also controlled by Vue
Without in-depth knowledge I would say that memory gets freed through the garbage collector. The memory is freed when it is no longer linked to its root.
This issue https://github.com/vuejs/vue/issues/6759 implies that the count of VueComponents
should decrease after the component is destroyed. This seems to be specific to keep-alive
though.
Ok, the issue is in the Vue itself, here is a simple test case https://jsfiddle.net/muy6kfn2/3/
And looks like it is fixed in latest version https://jsfiddle.net/0qb0kfmr/3/
From my findings the issue is caused by not detached event in case of component rendered with render
function and have event assigned inside with on
So closing as not F7 issue
@nolimits4web Thank you for your work on the issue! Much appreciated!
Thanks @nolimits4web
Hi
I am really enjoying f7-vue but I am running into a problem where loading a new page adds VueComponents to the memory heap without cleaning them up.
The issue in one of my applications is that after 80-100 navigation events the memory usage is out of control.
To reproduce this you can use do the following:
https://github.com/framework7io/Framework7-Vue-Webpack-Template
About
linkBack
linkAbout
ones could be released?About
linkShould it not remain at 103 because those 9 components are already in memory? Or at least they should be freed and then replaced by the new ones?
I have tried a couple of configuration options like turning off
domCaching
on theview
. When I addreload
to the links I can see that thedestroyed()
event hook is called on the components but they do not get removed from memory.Please let me know if I am misunderstanding an implementation detail here.
Thanks for all your hard work!