How can I prevent memory leaks when removing images in the DOM?

前端 未结 5 487
不思量自难忘°
不思量自难忘° 2020-12-23 11:50

There is a known bug in webkit that when you remove an image from the DOM, it doesn\'t free the memory associated with it.

This is an issue with single page apps tha

5条回答
  •  盖世英雄少女心
    2020-12-23 12:15

    Try setting the Javascript DOM tree object to "null".

    First, using something like the chrome developer tool interface, locate the object in the DOM tree hierarchy and inspect it and find the object that contains the binary of your image.

    Try setting that object to null, such as var obj = null;.

    That should tell Javascript that the child is no longer referenced and force the object's memory to be freed.

提交回复
热议问题