There’s no way to know if garbage collection was forced.  Create a method does does a for loop that creates 10,000 objects into mid-air.

 

For (var i:int=0; I < 10000; i++)

New Object();

 

That should trigger the garbage collector hopefully.

 


From: [email protected] [mailto:[email protected]] On Behalf Of jeff tapper
Sent: Thursday, July 27, 2006 5:56 AM
To: [email protected]
Subject: [flexcoders] Re: Tools for listing objects

 

Well, that experiment failed as well. 14 hours later, the same
objects are still listed in the dictionary.
Wed Jul 26 17:07:23 GMT-0400 2006
Testing56:Testing56
Testing19:Testing19
Testing38:Testing38
Thu Jul 27 08:50:31 GMT-0400 2006
Testing56:Testing56
Testing19:Testing19
Testing38:Testing38

Am I misunderstanding the usage of Weak References in the
Dictionary? Does anyone have any idea how this can be used to keep
track of what objects exist and which dont?

--- In [EMAIL PROTECTED]ups.com, "jeff tapper" <[EMAIL PROTECTED]> wrote:
>
> Ok, heres a sketch of what im trying now.
> App.mxml
> ====
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> layout="vertical" creationComplete="initApp()">
> <mx:Script>
> <![CDATA[
> import mx.managers.PopUpManager;
> import mx.managers.PopUpManagerChildList;
> import mx.core.IFlexDisplayObject;
> private var screenDict:Dictionary;
> private var scr1:IFlexDisplayObject;
> private function initApp():void{
> screenDict = new Dictionary(true);
> }
> public function createScreen
> (parent:DisplayObjectContainer,
> screen:Class,modal:Boolean=false):IFlexDisplayObject{
> var s:IFlexDisplayObject =
> PopUpManager.createPopUp(parent, screen,
> modal,PopUpManagerChildList.APPLICATION);
> screenDict[s] = s.name
> return s;
> }
> public function showObjects():void{
> trace(new Date());
> for (var i:* in screenDict){
> trace(i+":"+screenDict[i]);
> }
> }
> public function removeScreen
> (screen:IFlexDisplayObject):void{
> PopUpManager.removePopUp(screen);
> }
> private function makeScreen():void{
> if(scr1 == null){
> scr1 = createScreen
> (this,Testing,false);
> }
> }
> private function destroyScreen():void{
> removeScreen(scr1);
> scr1 = null;
> }
>
> ]]>
> </mx:Script>
> <mx:Button click="makeScreen()" label="make"/>
> <mx:Button click="destroyScreen()" label="kill"/>
> <mx:Button click="showObjects()" label="show"/>
> </mx:Application>
>
> Testing.mxml
> =====
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" width="400"
> height="300">
> <mx:Button click="this.dispatchEvent(new Event('foo'))"/>
> </mx:Panel>
>
> Now, as i run this, if i click make, kill, make, kill, show, The
> trace shows:
> Wed Jul 26 17:07:14 GMT-0400 2006
> Testing58:Testing58
> Testing20:Testing20
> Testing39:Testing39
>
> Implying that the screens arent really being destroyed. Perhaps I
> didnt wait long enough, so 5 minutes later, I tried the same
thing,
> with the same results. Maybe 5 minutes isnt long enough, so I'll
> leave it running over night and try again in the morning. But,
the
> fundemental question is, have i done enough to remove the
screens?
> Should the garbage collector clean the unused ones up, or have i
> somehow left a reference lingering?
>
> We have a very complex app, which I want to ensure we clean up all
> unused objects, but im having trouble finding a way to verify they
> are removed.
>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to