[Vm-beginners] Objective-C Bridge Memory Management

John McIntosh johnmci at smalltalkconsulting.com
Mon May 2 03:11:42 UTC 2011


Mmm the water is really deep in this pool.

This is no mapping.

Objective-C objects which get GCed get dealloc messages, there is no
way to feed that back to Squeak.

When a Smalltalk object gets GCed you should setup a weak relationship
so that on the finalization action you could then send release to the
companion Objective-C object.
I never did this as it is tricky, difficult and nasty when it goes
wrong. Still you might be lucky when you implement it, you'll find
working examples in the image.

Look for use of the autorelease pool in the objective-c bridge.

The event loop runs each time you call the get next primitive, so
making an auto-released object without a pool would cause the object
to be released at an undetermined time.

Zombies are of course released when a unix process, aka os-x
application, ios app terminates. All resources are returned for reuse
by other users.

As an exercise think about the asUTF8String and what happens, welcome
to managed memory allocation.
Oh yes a finalization solution work work fine for this case.


On Sun, May 1, 2011 at 10:38 PM, Sean P. DeNigris <sean at clipperadams.com> wrote:
> How does Obj-C garbage collection map to Squeak?
>
> For example:
> * When an Obj-C object is garbage collected in Squeak, is the release
> propagated back to Obj-C (does it even have to be)?
> * Is it safe to autorelease objects? What is the "event loop" of obj-c code
> called from Squeak?
> * If objects become zombies, how long do they hang around? Are they finally
> destroyed when I quit the image?
>
> Thanks.
> Sean--
> View this message in context: http://forum.world.st/Objective-C-Bridge-Memory-Management-tp3489203p3489203.html
> Sent from the Smalltalk VM - Beginners mailing list archive at Nabble.com.
> _______________________________________________
> VM-beginners mailing list
> VM-beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
>



-- 
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================


More information about the VM-beginners mailing list