Is Unhooking event handlers needed to avoid memory leaks in IE

后端 未结 2 1051
执笔经年
执笔经年 2021-01-16 12:12

I am having some memory leak problems in IE.

I have been reading, that not unhooking event handlers in IE, could cause memory leaks. Is this true?
Could my memo

2条回答
  •  失恋的感觉
    2021-01-16 12:57

    Douglas Crockford has an excellent post on JSscript memory leaks (JScript is IE's implementation of JavaScript/ECMAScript).

    It basically comes down to this: IE has separate memory management (and thus garbage collection) for the DOM and for JScript. Because of this, IE has trouble cleaning up the cycling references between DOM objects and event handlers.

    The way to work around this is to make sure that you always remove the event handlers from the DOM objects (or set them to null) before you throw away the DOM object.

提交回复
热议问题