> in the removed view I get ride of the listeners in the unload event The only 'unload' event I know of in Flex 2 is in SWFLoader. Are your views SWFs that you're loading into a SWFLoader?
- Gordon ________________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jason Hawryluk Sent: Friday, June 23, 2006 12:21 AM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Garbage collection and removeChild [Flex 2 beta 3]? Thank you, this clears some things up. :) I was actually allocating memory up to 100mb and then seeing if it's collected by letting it sit there with no activity, and watching the process memory usage (couldn't think of another way). "You can later remove a component from a container using the removeChild() method. If there are no references to the component, it is eventually deleted from memory by the garbage collection mechanism of Flash Player." The above taken from the doc's, lead me to believe that there was a garbage collection process every (x)min's. If the player only does this when it needs to get back memory, then that would explain why I did not see it collected. What lead me to the question was the following scenario: I have a single component based on the viewstack for the views, this component listens for event state changes in the program to load new views, the events it gets come from another class (think observer pattern). So with this I can load multiple copies of a view with different data(this is where I seen a problem). Even though a view was removed from the viewstack it still received data change events (which it listens to in order to see if it needs to load new data (think chain of responsibility here) where each view gets the event and decides if the data is destined for it (the data it self is just a guid that I use to reference the xml data needed to be loaded). The scenario may seem weird, but no object knows what data is being accessed except the view that is responsible for displaying it. If the view was really unloaded then the event should not get through. So now I remove a view, and in the removed view I get ride of the listeners in the unload event, clean up any child objects/classes/data providers etc.. So the view >> dataprovider >> modelloader >> etc.. >> controller >> etc.. >From what I understand from your answer is that if the view is removed, and I clean up the listeners and "local" references i.e. (set dataprovider and controller to null) view >> dataprovider >> controller Then I should be alright. Is this correct? My original thinking was that if it's removed to the garbage collection how is it that it's still getting the events? I was thinking that this was a protected space. I can't get the instance back from the garbage collection, however the instance is still very much alive and kicking. Is this making sense? Are these correct assumptions? Thank you for your help. Jason -----Message d'origine----- De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] la part de Gordon Smith Envoyé : vendredi 23 juin 2006 08:30 À : flexcoders@yahoogroups.com Objet : RE: [flexcoders] Garbage collection and removeChild [Flex 2 beta 3]? > it does not seem to be collected What are you doing that you think should cause it to be collected? Do you keep allocating memory indefinitely? An object may never get garbage collected unless the Player decides it needs the memory. > Should one have to remove all objects created through the > or just on the child being removed? I'm not really following your texavery >> toto >> titi example because you didn't explain which one you're removing. Let's suppose you're removing toto as a child of texavery. If you're not keeping any references to toto or titi, then both become eligible for garbage collection; the fact that toto holds a reference to its child titi doesn't matter, because the two of them are isolated from all other objects. > Is there a way to force the garbage collection clean up, > or destroy an object completely? There are no APIs for controlling garbage collection. Once there are no references to an object, it becomes eligible for garbage collection. It doesn't mean that it actually gets garbage collected. Is your app exhibiting unbounded memory growth to the point where it consumes all the machine's memory? - Gordon ________________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Harald Dehn Sent: Thursday, June 22, 2006 3:55 AM To: flexcoders@yahoogroups.com Subject: WG: [flexcoders] Garbage collection and removeChild [Flex 2 beta 3]? Is there any answer to this thread? I do have the same problems with the garbage collector. ________________________________________ Von: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] Im Auftrag von sourcecoderia Gesendet: Dienstag, 20. Juni 2006 18:06 An: flexcoders@yahoogroups.com Betreff: [flexcoders] Garbage collection and removeChild [Flex 2 beta 3]? >From the documents when using removeChild the removed display item is added to the garbage collection for later removal. However I'm reusing component instances and creating new instance of the same (a sort of tabbed interface where children are created and removed at will. The listeners for the child component are removed and other objects set to null, but; it does not seem to be collected. Should one have to remove all objects created through the chain or just on the child being removed? I.e. if I instantiate a class called toto through a component called texavery and toto creates an instance of titi do I have to unload all objects created by or in the children following the entire chain texavery >> toto >> titi where each one unloads it's owned/created objects? Or is this cleaned up from the child object on down? Is there a way to force the garbage collection clean up, or destroy an object completely? I did wait to see if it unloaded 25mins and still no change in the process memory usage. However I'm only at this time unloading objects created by the child component and not it's children's objects. So unload the entire chain or just the first ? Is removeChild working properly ? How is this supposed to work, and are there any best practices in regards to this? Thanks, Jason ------------------------ Yahoo! Groups Sponsor --------------------~--> See what's inside the new Yahoo! Groups email. http://us.click.yahoo.com/2pRQfA/bOaOAA/yQLSAA/nhFolB/TM --------------------------------------------------------------------~-> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/