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: Erik Arvidsson Date: October 29, 2002
Its a bit ugly but if that solves the worst memory leaks I'm willing to use a global cache.

I would use a hash table for the cahce so that items can be removed faster and cleaner. Otherwise it is a sound idea.

Thanks for spending time on this. I'll add your name to the credits if you do not mind?

erik

-------------------------------------------------------

I was able to break all the closures.
create a global array, _globalMenuCache add a new member to MenuBar, Menu and MenuItem, this._ordinal In each object's constructor set this._ordinal = _globalMenuCache.length, then _globalMenuCache[this._ordinal] = this Everywhere a local function is used, call a global instead, and pass in the objects _ordinal value. In the global function set oThis = _globalMenuCache[ordinal] 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