[Mono-osx] Fwd: Objective-C and Mono's GC

Martin Smith martin.smith.jr at gmail.com
Tue Jan 13 17:20:16 EST 2009


Sorry... forgot to reply-all.

Actually, i think your problem was pretty close to mine except that I'm not
trying to use the Obj-C GC at all (we're using the classic retain-release
mechanism).  I guess when Boehm does its scan it doesn't see the instances.
Your solution will probably end up looking pretty much like ours.

Thanks for the response!
Martin


On Tue, Jan 13, 2009 at 12:44 PM, Duane Wandless <duane at wandless.net> wrote:

> I think I understand your problem... but it might be different than what I
> encountered.  Basically there are issues with the GC collectors of both C#
> and Obj-C.   Neither knows about objects created in the other world.  In my
> application I have an Obj-C application that runs and embeds Mono.  The Mono
> code creates lots of C# objects.  When the GC from Obj-C runs it destroys my
> C# objects that are created using Monobjc, or mobjc (which is faster and a
> smaller memory footprint).
>
> The basic recommendation is don't use the Obj-C GC when embedding Mono.  So
> what I did was:  in my constructor for my C# objects I send an event to the
> Obj-C world to add the object to a list.  Then in the deconstructor I
> release them from the Obj-C list.  This allows the use of the Obj-C GC.
>
> Best of luck.
>
> On Tue, Jan 13, 2009 at 3:10 PM, Martin Smith <martin.smith.jr at gmail.com>wrote:
>
>> Hello,
>>
>> We are working on an application where we're embedding Mono in an
>> Objective-C application.  One of the issues that we're seeing is that if the
>> GC does not "see" pointers that are stored in Objective-C objects.  The side
>> effect is that when we run our applications, the Obj-C objects will have
>> instance variables that will eventually raise a SIGSEV
>> (NullReferenceException) whenever the garbage collector runs.
>>
>> Does anyone else have experience with this problem?  I know one of the
>> things we could probably do is maintain a data structure that stores all the
>> "live" mono pointers and then write smart pointer classes that explicitly
>> maintained ref counts on these objects, but I'm wondering if there's an
>> easier way.
>>
>> Thanks in advance,
>> Martin
>>
>> _______________________________________________
>> Mono-osx mailing list
>> Mono-osx at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-osx
>>
>>
>
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20090113/87c40348/attachment.html 


More information about the Mono-osx mailing list