-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Description
我在做我们产品的内存快照分析时发现了这个问题:

通过快照发现 imageOnLoad 已触发,但 pending 队列仍保留很多 pendingWrap 对象,导致内存泄漏。
#339 与这个issue相似,createOrUpdateImage 函数在获取已存在 image时,是通过判断图片元素是否有尺寸来决定要不要添加到 pending 队列。
zrender/src/graphic/helper/image.ts
Line 65 in 379f91f
| !isImageReady(image) && cachedImgObj.pending.push(pendingWrap); |
zrender/src/graphic/helper/image.ts
Line 104 in 379f91f
| return image && image.width && image.height; |
但如果图片已加载失败(不会再触发
imageOnLoad回调),图片的width和height都会为0,则后续的调用将导致这个图片的pending队列一直增加,进而产生内存泄漏。
或许可以添加一个图片是否已完成加载(无论成功与否)的标记,通过该标记判断是否需要添加到pending队列?
### Tasks
- [ ] https://github.com/ecomfe/zrender/pull/1073
Metadata
Metadata
Assignees
Labels
No labels