How to remove DOM elements without memory leaks?

前端 未结 5 1794
無奈伤痛
無奈伤痛 2020-11-28 21:29

My JavaSript code builds a list of LI elements. When I update the list, memory usage grows and never goes down. I tested in sIEve and it shows that the browser

5条回答
  •  情歌与酒
    2020-11-28 21:59

    If you have to "post-fix" leakage, and must do so without rewriting all your code to take closures, circular references etc in account, use Douglas Crockfords Purge-method prior to delete:

    https://crockford.com/javascript/memory/leak.html

    Or use this closure-fix workaround:

    Leak Free Javascript Closures

提交回复
热议问题