WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 Memory Leaks in Menu4, Micha Schopman, July 1, 2002
     Re:Memory Leaks in Menu4, Erik Arvidsson, July 1, 2002
             Re:Memory Leaks in Menu4, Ed Schiebel, October 25, 2002
                 Re:Memory Leaks in Menu4, Erik Arvidsson, October 27, 2002
                     Re:Memory Leaks in Menu4, Ed Schiebel, October 29, 2002
                         Re:Memory Leaks in Menu4 , Ed Schiebel, October 29, 2002
                             Re:Memory Leaks in Menu4 , Erik Arvidsson, October 29, 2002
                         Re:Memory Leaks in Menu4, Erik Arvidsson, October 29, 2002
                             Re:Memory Leaks in Menu4, Ed Schiebel, October 29, 2002

Subject: Re:Memory Leaks in Menu4 From: Ed Schiebel Date: October 29, 2002

I was able to break all the closures.

  1. create a global array, _globalMenuCache
  2. add a new member to MenuBar, Menu and MenuItem, this._ordinal
  3. In each object's constructor set this._ordinal = _globalMenuCache.length, then _globalMenuCache[this._ordinal] = this
  4. Everywhere a local function is used, call a global instead, and pass in the objects _ordinal value.
  5. In the global function set oThis = _globalMenuCache[ordinal]
  6. the global function now has access to the object.

I'm still experiencing a significant memory leak though.

--ed


From: Erik Arvidsson
Sent: October 27, 2002
Subject: Re:Memory Leaks in Menu4

It is of course impossible to remove the closures. Closures are what makes JS such a good language. Without closures all objects would need to be global.

However, I'll see if I can break a few of these circular references. I have tried this before and I did not see any improvements. The following features are required.

attachEvent, setTimeout: Both require function expressions to encapsulate local objects.

I have tried detachEvent but that did not help at all.

erik





Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX