gnash-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-dev] GC: static (kept alive) resources


From: Sandro Santilli
Subject: [Gnash-dev] GC: static (kept alive) resources
Date: Fri, 29 Jun 2007 02:35:05 +0200

On Tue, Jun 26, 2007 at 11:23:08AM +0800, zou lunkai wrote:

>  1. INITIALIZATION: all managed objects are constructed in the
> UNREACHABLE state, no scan needed for initialization.
>  2. MARK SCAN: for each reachable object, if the object isn't marked
> as REACHABLE then mark it so and recurse.
>  3. CLEANUP SCAN: Release all resources which are still markes as
> UNREACHABLE, mark the remaining as UNREACHABLE to be ready for next
> scan.
> 
> "
> In step 1, if all objects are construted as UNREACHABLE, who make them
> to be  REACHABLE? I don't see this happen in step 2 and 3.

It's step 2, each reachable object is marked as REACHABLE in this step.

> In step2, where are the "reachable objects"?  Since all objects in
> step1 are UNREACHABLE,  after you step to step2 from step1, all
> objects constructed in step1 are still UNREACHABLE as I see.  Answerer
> question one would also answer this.

Reachable objects are only known by other objects. All start in the GcRoot
by calling it's markReachableObjects method.

> I just can not stop thinking about the GC algorithm intuitively in my
> brain like this:
> 
> 1. INITIALIZATION: all managed objects are constructed in the
> REACHABLE state, no scan needed for initialization.

There's no scan for the initialization currently. It's just the GcResource
constructor setting the reachable flag as false.

> 2. MARK: mark the specified object to be UNREACHABLE  in the REACHABLE
> object list. (This is done by user)

How do you know which object is NOT reachable if you can't reach it ? :)

> 3. CLEANUP SCAN:  Release all resources which are marked as
> UNREACHABLE, keep the REACHABLE objects alive.
> 
> These are some assumptions I made, which might lead my
> misunderstanding about the GC algorithm, I need your check.
> (1)An object is reachable means it is in a valid state and can be
> accessed by the user, otherwise not.

Right. A reachable object is an object which you can reach starting
from the GcRoot and following references.

> (2)An object is unreachable after it is deleted or a deletion
> instruction be issured on it.

Not exactly. An object is unreachable when it can NOT be reached
by following a path of pointers from the GcRoot.

> (3)If I create a new object, of course I need it to be reachable,
> since I might need to use it immediately.

It *is* reachable but not marked as such. This is to avoid an additional
scan to mark it unreachable just before the collector starts.
The whole point is that we want to get rid of *everything* by default, and
just save the objects that we can still reach.

--strk;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]