Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Fix] $slots children references cause memory leak, replace by creating the 'keeps' vnodes when it needs #87

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

Merged
merged 1 commit into from
Mar 2, 2019

Conversation

imwtr
Copy link
Contributor

@imwtr imwtr commented Feb 23, 2019

Recently I found that my page crashed when data set increases(about 2000 items, and 1k per item),
visual(size and remain together) was just 50, but the memory use was nearly 1G.

And the finite live demo performs similarly. Maybe it's a memory leak, or a memory waste, simple 100,000 items retain 64M default , and 150M maximum after scrolling up and down.
default
50 'keeps' size and all vnodes default, more vnodes and vueComponent are created but not deleted after.
maximum
I think it should be a memory waste, virtual item vnodes and components have references with VirtualList in this way. When data set increases, it maybe a memory problem.

<VirtualList :size="50" :remain="6" :bench="44" class="list" :start="startIndex">
    <Item v-for="(udf, index) of items" :index="index" :key="index"></Item>
</VirtualList>


Solution is quite simple, pass pure data and the itemComponent to the container, and create vnodes what we need VirtualList, which can cut down references across objects.

<VirtualList :size="50" :remain="6" :bench="44" class="list" :start="startIndex"
    :items="items" :item-component="itemComponent" :item-binding="itemBinding">
</VirtualList>

See more detail at changed and the example 'finite-m' ,
for comparison, the new way saves memory indeed ~

@imwtr imwtr changed the title [Fix] $slots children references cause memory leak, replace by creating the 'keeps' vnodes when it needs[Fix] $slots children references cause memory leak, replace by creating the 'keeps' vnodes when it needs [Fix] $slots children references cause memory leak, replace by creating the 'keeps' vnodes when it needs Feb 23, 2019
@tangbc
Copy link
Owner

tangbc commented Feb 27, 2019

It's great, but busy these days, I will finish after soon.

@tangbc tangbc merged commit 3bc5a43 into tangbc:master Mar 2, 2019
@eldor
Copy link

eldor commented Mar 8, 2019

Hi @tangbc, any change of a new version tag for this merge?

@tangbc
Copy link
Owner

tangbc commented Mar 8, 2019

@eldor I plan publish after fix #88 , it would be soon.

@linweiwei123
Copy link

Memory leak still exists on the lastest version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants