Memory cannot be released because the innerHTML Association is changed.

Source: Internet
Author: User

When using JavaScript to perform DOM operations, you will always encounter interesting things depending on the browser. The problem described this time is related to the Association of IE6 and innerHTML: Detailed records. When ie6 operates on the innerHTML and dom of the deleted node, the memory of the deleted node will no longer be released, setting the attribute and css for deleting a node is no problem.

Attention is often paid to the callback processing node in xhr. The node to be processed may have been deleted.

Test code:

 
 
  1. < Div Id="P"> 
  2.  < A Id="C"> 
  3. Xx
  4.  </> 
  5. </Div> 
  6.  
  7.  
  8. < Script> 
  9.  Window. onload=Function(){
  10. VarA=Document. GetElementById ("c ");
  11. Document. getElementById ("p "). InnerHTML="";
  12. // Css, attribute no problem
  13. //A. style. width="1px";
  14. //A. href="Xx";
  15. // Set innerHTML to change the innerHTML Association.
  16. A. innerHTML='Yy';
  17. // Neither dom a nor span can be released
  18. // A. appendChild (document. createElement ("span "));
  19. //A=Null;
  20. }
  21.  </Script> 

Under normal circumstances:

After the page is executed, there are 6 in-use nodes and a has been released.

 

InnerHTML Association:

Changed 7 innerHTML in-use nodes of the deleted node, and a cannot be released.

 

  1. Detailed description of Array extensions in Javascript
  2. What is JSON? Data format prepared for JavaScript
  3. 10 most commonly used JavaScript udfs
  4. Some extended thoughts on loading JavaScript events
  5. Summary of JavaScript usage: From BOM and DOM

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.