[MacRuby-devel] Embedding MacRuby

Laurent Sansonetti lsansonetti at apple.com
Tue Aug 19 13:17:32 PDT 2008


On Aug 19, 2008, at 12:55 PM, Benjamin Stiglitz wrote:

>>> - Need to be able to clean up (full reset) of the MacRuby VM -
>>> release
>>> all defined objects, undefine classes.
>>> Is this even possible? How costly would it be, time-wise?
>>
>> I don't think this is possible, right now. But we can work on this.
>
> Tearing down the old classes would be really difficult, since they
> might be referenced by objects that have been passed to the Obj-C
> side. I suppose if you used unique Objective-C class names and just
> cleared the Ruby->ObjC map, it wouldn’t be as bad, but then you need
> extra shenanigans to use Ruby classes from Objective-C.

In fact, in my private branch (to be merged in trunk very soon), the  
Ruby classes semantics are now fully implemented in Objective-C  
classes (so there is no such thing as a Ruby class anymore). I still  
keep a map of classes that were created by Ruby, so it would just be a  
matter of removing them from the runtime and cleaning the hash.

Obviously, if there is still a reference to them in the Objective-C  
side, it's not going to be nice (AFAIK classes are not allocated from  
the autozone). This feature would have to be used very carefully.

>> At a glance, the only problematic thing would be to remove C
>> extensions that were loaded.
>
> dyld can do this in Leopard. Hooray.

Oh nice, I will look at this :)

Laurent


More information about the MacRuby-devel mailing list