Repository navigation
Conversation
kairyou
requested review from
HaixingOoO,
NWYLZW,
RylanBot,
ZWkang,
anlyyao,
carolin913,
honkinglin and
uyarn
as code owners
December 4, 2026 02:06
Collaborator
TDesign Component Site Preview Open
|
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

🤔 这个 PR 的性质是?
🔗 相关 Issue
无
💡 需求背景和解决方案
问题: 开启虚拟滚动 (或表头吸顶 / 表尾吸底) 的 Table, 每次
data或columns变化都会在表格内容区上再挂一对mouseenter/mouseleave监听, 旧的从不移除, 造成内存泄漏.useAffix里依赖[props.data, props.columns, ...]的 effect 调用了addHorizontalScrollListeners(), 但没有返回清理函数. 每次渲染的监听函数都是新闭包, 闭包引用了当次渲染的props, 也就引用了整份data和columns(包括cell渲染函数及其闭包). 所以每换一次数据, 就有一整份旧数据无法回收.影响: 定时刷新数据的虚拟滚动表格, 内存会持续增长. 我们的场景是数千行的表格每 5 秒刷新一次, 约一小时后页面内存涨到 4GB 以上, 渲染进程因内存不足 (OOM) 被结束. 堆快照里的引用链是: 内容区元素的事件监听列表 → 几十个
onTableContentMouseEnter→ 当次渲染的props→columns→cell→ 那一轮的全部行数据.修改: 这个 effect 返回
removeHorizontalScrollListeners. 下次依赖变化或卸载时, 先移除上一次挂上的监听, 再挂新的. 与上方依赖showElement的 effect 的写法一致.测试: 新增用例: 200 行的虚拟滚动表格换 10 次
data/columns, 断言同一元素上的mouseenter监听数不变. 修改前是 1 → 21, 修改后保持 1.packages/components/table/__tests__下的测试全部通过.我们在 1.16.9 上用同样的改动 (es / lib / cjs / esm 产物) 验证过: 约 1300 行的虚拟滚动表格连续刷新 200 次, 堆增长从约 1GB 降到约 30MB.
📝 更新日志
tdesign-react
data、columns变化时重复挂载滚动监听且不移除, 导致内存泄漏的问题@tdesign-react/chat
tdesign-mobile-react
☑️ 请求合并前的自查清单