In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about the memory release problems that need to be paid attention to in JS programming under IE. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
And everyone focus on IE JS programming to pay attention to the memory release problem, in IE JS programming, the following programming methods will cause the problem that even if IE is closed, the memory can not be released, the following classification is given.
Memory release problems that should be paid attention to in IE JS programming
In JS programming under IE, the following programming methods will cause the problem that memory cannot be freed even if IE is turned off, which is classified below.
1. The property added to the DOM object is a reference to an object.
Example:
VarMyObject= {}; document.getElementById ('myDiv'). MyProp=MyObject
Solution:
Write: document.getElementById ('myDiv') .myProp=null in the _ window.onunload event
2. DOM object and JS object refer to each other.
Example:
FunctionEncapsulator (element) {this.elementReference=element; element.myProp=this;} newEncapsulator (document.getElementById ('myDiv'))
Solution:
Write: document.getElementById ('myDiv'). MyProp=null in the onunload event
3. Bind events to the DOM object with attachEvent.
Example:
FunctiondoClick () {} element.attachEvent ("onclick", doClick)
Solution:
Write: element.detachEvent ('onclick',doClick) in the onunload event
4. Execute appendChild from outside to inside. At this point, even if removeChild is called, it cannot be released.
Example:
VarparentDiv=document.createElement ("div"); varchildDiv=document.createElement ("div"); document.body.appendChild (parentDiv); parentDiv.appendChild (childDiv)
Solution:
Perform appendChild from the inside out:
VarparentDiv=document.createElement ("div"); varchildDiv=document.createElement ("div"); parentDiv.appendChild (childDiv); document.body.appendChild (parentDiv)
5. Rewriting the same property repeatedly will cause a large amount of memory consumption (but memory will be freed when IE is closed).
Example:
For (iSuppli)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.