Re: Garbage Collection

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Mon, 27 Jun 2005 17:18:32 -0700, Robert Craig
<guest at RapidEuphoria.com> wrote:

>Vincent wrote:
>> But Rob claims Euphoria ignores cyclic structures of pointers. 
I found reference counting, done properly, made cyclic structures
impossible:

<snip>

>Robert Craig wrote:
>Here's how a cycle could occur (without precautions):
>
>     A[5] = A
>
IIRC, in posetf it went something like this:
1) "= A" made the refcount of A increase to 2, the same way it would
in the statement "B = A".
2) "A[5] =" noticed a refcount>1 and therefore cloned the root
sequence before allowing the subscripted assignment (the same way it
would in B=A followed by A[5]=0). The assignment would itself decref
the "original" A (aka A[5]), putting it back to 1.

Regards,
Pete
PS a subsequent A={} would recursively deref A, and hence deref A[5],
consequently freeing it.
PPS Rob has been playing this game longer than me, so I accept the
above may be non-optimal, but it seemed to work for me (and I had
heavy/exact memory counting code in there to prove it)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu