[squeak-dev] Re: shared object between main.exe and Squeak.dll

Igor Stasenko siguctua at gmail.com
Sat May 8 11:03:41 UTC 2010


On 8 May 2010 11:08, Ang BeePeng <beepeng86 at yahoo.com> wrote:
>
> Hi, thanks.
>
> Do you mean I can't just leave pointer to object on extraRoots[], and simply
> get back to it after some time. That mean, there's no way no keep object out
> of touch of GC forever. addGCRoot() have temporary effect only, is it true?
>

OH.. looks like we're going to move in circles with this.
With addGCRoot() you specifying an additional _static_ memory location, where
some root oop will be stored.
A GC takes this oop into account when marking a heap during mark
phase, so your oop
can never become a garbage. But as well as any other object, it can be
moved in memory due to compaction,
and oop value will be updated, while oop will still point to the very
same object, but moved into a different memory location.
Hence you need an indirection, so you still can access the very same
object after GC.

oopPtr = malloc(4);

*oopPtr = someOop;
addGCRoot(oopPtr);

oop = *oopPtr;
.. do something which may cause GC ...
oop' = *oopPtr;

here, when you reading a oop stored in oopPtr, before and after GC,
they can be different,
but still pointing to same object in object memory.

The temporary effect of addGCRoot() lies in another plane:
 extra roots table are not persisted within image.
So, if you save an image and then restart it, you'll have no any extra
roots initially.

> Thanks.
>
> Ang Beepeng
> --
> View this message in context: http://forum.world.st/shared-object-between-main-exe-and-Squeak-dll-tp2023185p2135959.html
> Sent from the Squeak - Dev mailing list archive at Nabble.com.
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list