Sign In/My Account | View Cart  
advertisement

Article:
 Object-oriented JavaScript
Subject: Nice articles, but a major imprecision
Date: 2006-06-08 07:23:35
From: jdodds
Response to: Nice articles, but a major imprecision

Using closures for information hiding in a JavaScript object that uses only JavaScript native objects doesn't pose a memory leak risk. Memory leaks are not inherent in using closures.


The IE memory leaks have three pre-conditions:
1.) IE,
2.) a circular reference (which may be created by a closure),
3.) a host object implemented as a COM object.


It's not closures that are the problem but the way that COM based host objects are garbage collected by IE.


I recently wrote about closures on my blog:
http://jrdodds.blogs.com/blog/2006/05/javascript_clos.html


No Previous Message Previous Message Move up to Parent Message Up Next Message No Next Message


Titles Only Titles Only Newest First
  • Nice articles, but a major imprecision
    2006-06-08 07:40:35 Greg.Brown [Reply]

    All true. Which is why I said they "can" cause memory leaks "if not used properly". :-)


    I suppose it would have been more accurate to say that they "can cause memory leaks in IE if not used properly". I just didn't want to get into the details in my reply, which is why I included the MSDN reference.


    Greg





Sponsored By: