Skip to content
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

修复throttle闭包导致的内存泄漏问题 #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pjxxcc
Copy link

@pjxxcc pjxxcc commented Jun 30, 2022

此throttle函数存储了最后一次触发事件时的参数arguments和context,导致如果后续不再触发此事件,那么上一次触发事件时的dom以及组件都无法被内存回收。

比如在vxe-table中,触发mouse-wheel后表格会被缓存,后面即使销毁了表格,其内存也无法被释放。当然因为mouse-wheel事件是注册在window上的,在空白区域再次滚动鼠标滚轮,内存就会得以释放,但是新的内容又会被缓存,再关闭另一个表格或者其他组件,内存同样无法被回收。

image

image

image

此throttle函数存储了最后一次触发事件时的参数arguments和context,导致如果后续不再触发此事件,那么上一次触发事件时的dom以及组件都无法被内存回收。

比如在vxe-table中,触发mouse-wheel后表格会被缓存,后面及时销毁了表格,其内存也无法被释放。当然因为mouse-wheel事件是注册在window上的,在空白区域再次滚动鼠标滚轮,内存就会得以释放。
@Sapphire2k
Copy link

@xuliangzhan 大佬 这个能处理一下吗?今天排查到WheelEvent确实会导致内存溢出

@Sapphire2k
Copy link

Sapphire2k commented Mar 14, 2024

image

@xuliangzhan 大神关注一下这个?

只是左右滑动,开启了虚拟滚动

vxe-table v3.6.13
xe-utils v3.5.14

PS: 似乎是在keep-alive下会出现

@changxuexu
Copy link

怎么解决的,也遇到了同样的问题,不过用的是v 4.5.22版本

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.

3 participants