Thank you! This clears thing up for me, I appreciate all your help.. :)
 
Now, Can't talk need to download :)
 
Jason
 
 
-----Message d'origine-----
De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]De la part de Gordon Smith
Envoyé : mardi 27 juin 2006 23:05
À : flexcoders@yahoogroups.com
Objet : RE: [flexcoders] Garbage collection and removeChild [Flex 2 beta 3]?

> If b is the only object holding a reference to c, and b is removed, would c be removed as well without further intervention on my part?

Yes.

> So if I remove b, and b references objects that are held nowhere else, are those references, references cleaned up?

Yes.

- Gordon


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jason Hawryluk
Sent: Tuesday, June 27, 2006 12:00 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Garbage collection and removeChild [Flex 2 beta 3]?

b has an instance of c, a way to get to c's events could be done easy enough. I suppose the question is do I need to do that. If b is the only object holding a reference to c, and b is removed, would c be removed as well without further intervention on my part? c in this case not being held by another object.

After looking a bit in the Flex source, I don't see much if any removal/cleanup code.

So if I remove b, and b references objects that are held nowhere else, are those references, references cleaned up?

I'm not at this time noticing anything overly strange, I’m just looking for confirmation that this is the correct assumption.

Thanks for helping on this.

Jason

-----Message d'origine-----
De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]De la part de Gordon Smith
Envoyé : lundi 26 juin 2006 23:10
À : flexcoders@yahoogroups.com
Objet : RE: [flexcoders] Garbage collection and removeChild [Flex 2 beta 3]?

If you have

a

|

b

|

c

and you do a.removeChild(b), do you have some way to remove listeners to c's events? c won't get a 'remove' event.

- Gordon


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jason Hawryluk
Sent: Saturday, June 24, 2006 12:07 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Garbage collection and removeChild [Flex 2 beta 3]?

Opps sorry, the remove event. No they are not swfs.

Jason

-----Message d'origine-----
De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]De la part de Gordon Smith
Envoyé : samedi 24 juin 2006 01:13
À : flexcoders@yahoogroups.com
Objet : RE: [flexcoders] Garbage collection and removeChild [Flex 2 beta 3]?

> 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: [EMAIL PROTECTED]ups.com [mailto:[EMAIL PROTECTED]ups.com] On Behalf Of Jason Hawryluk
Sent: Friday, June 23, 2006 12:21 AM
To: [EMAIL PROTECTED]ups.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 : [EMAIL PROTECTED]ups.com [mailto:[EMAIL PROTECTED]ups.com]De la
part de Gordon Smith
Envoyé : vendredi 23 juin 2006 08:30
À : [EMAIL PROTECTED]ups.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: [EMAIL PROTECTED]ups.com [mailto:[EMAIL PROTECTED]ups.com] On
Behalf Of Harald Dehn
Sent: Thursday, June 22, 2006 3:55 AM
To: [EMAIL PROTECTED]ups.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: [EMAIL PROTECTED]ups.com [mailto:[EMAIL PROTECTED]ups.com] Im
Auftrag von sourcecoderia
Gesendet: Dienstag, 20. Juni 2006 18:06
An: [EMAIL PROTECTED]ups.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

__._,_.___

--
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