Skip to content

meteor199/vue3-hoist-static-memory-leak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Problem

Problem

静态节点优化会在闭包中创建一个 hoisted${num} 的变量,之后渲染时,会将 hoisted.el 设置为dom。假如此组件中有事件监听,则会造成实例无法回收,从而造成内存泄漏。

Static hoist will creates a hoisted variable in the closure, and later sets dom to hoisted.el when rendering. If there are event listeners in the component, the component instance cannot be recycled, resulting in a memory leak.

Object reference chain:

  • hoisted
  • hoisted.el
  • hoisted.el.parentElement
  • hoisted.el.parentElement.children
  • children.onClick
  • createInvoker
  • instance

Step

  • Open dist/index.html
  • Click click button three times.
  • Open memory panel in chrome devtools, then take heap snapshot, then search BigData。

memory

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published