Hi, exactly "The garbage collector will not remove references to delegates that are still being used". Doesnt that mean that if you already nicely set your delegates to null, you are done?
Example: obj.ref = Delegate.create (otherObj, otherFunc); As long as obj.ref is in memory, otherObj and otherFunc will be too. Now if I do obj.ref = null, the delegate can be removed, as will the otherObj and otherFunc. Since obj.ref pointed to the inner function, which held a reference to the activation object containing otherObj and otherFunc, they couldnt be removed before, but after nulling the ref, they can? I did some other tests, to check if eg function init() { var myVar = 10; obj.ref = Delegate.create ()... } would cause myVar to be kept as well (as it would have been when you'd done obj.ref = function() {...}), but that was not the case. It seems to me the biggest pitfall would be code in which you'd go: function init(clip:MovieClip) { //1:setup handlers here //2:declare some variables here //etc etc clip.onEnterFrame = function () { //code goes here } } without relealizing, that becoz of the function assignment to clip, everything you have done under //1 and //2 is still in memory, and that you should be aware of this. I don't see how lots and lots of delegates, whose references are *appropriately released *will cause the problems described? greetz JC On 10/24/06, Alias™ <[EMAIL PROTECTED]> wrote:
The garbage collector will not remove references to delegates that are still being used - only ones that are no longer being referenced by anything else. It uses reference counting, so this will not cause any wierd That's a great article - although I now have to go through all my code and figure out where I need to call Delegate.destroy()... I have a VJing app which gets more and more unreliable the longer it runs and I bet this is why. HTH, Alias On 24/10/06, Hans Wichman <[EMAIL PROTECTED] > wrote: > > Hi Dimitrios, > > i was reading your article and the referenced article in which it says: > > Once the inner function is removed from memory (for instance if the object > to which the inner function was attached is removed), then the unique > reference to the activation object also gets deleted and the garbage > collector will (should) delete both the inner function and the activation > object of the outer function at the same time. > > Now the inner function is what is returned when you use Delegate.create. > It > seems to me mostly when using a Delegate, you want it to have those > references until you dont need the delegate itself anymore. So setting the > reference to the inner function to null, should take care of the rest? I'm > probably missing something here. > > greetz > JC > > On 10/16/06, Dimitrios Bendilas <[EMAIL PROTECTED]> wrote: > > > > Hello everyone, > > > > I had a really big issue recently, when I realized that the performance > of > > a large-scale game > > I built in Flash dropping substantially after 1/2 hour of gameplay, to > the > > point where > > the game became waaaay too slow to play. > > > > After exhausting tests I found out that this was caused by the extended > > use of Delegates > > with parameters (I always make sure I don't leave garbage sitting around > > when I destroy > > objects of all of my classes, so that was not the issue). > > > > Spending one week on this, I managed to spot the problem and find a > > solution, > > writing a new Delegate class that was taking care of cleaning up > function > > objects. > > > > I thought this would interest quite a few people, so I wrote an article > on > > this. You can > > read at www.zefxis.gr/article-delegates. You can also download the > > Delegate class > > I wrote and use it for you projects. > > > > I would appreciate any comments on this! > > > > Thanks, > > > > Dimtirios > > > > > > > > _______________________________________________ > > Flashcoders@chattyfig.figleaf.com > > To change your subscription options or search the archive: > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > > > Brought to you by Fig Leaf Software > > Premier Authorized Adobe Consulting and Training > > http://www.figleaf.com > > http://training.figleaf.com > > > _______________________________________________ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
_______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com