D/Objective-C 64bit

Christian Schneider via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Wed Oct 29 08:09:18 PDT 2014


> I tried running your code and could observe the behavior. 
> Although I have not been able to figure you why it behaves like 
> this. In general there are a couple of things to think of and 
> watch out for when interfacing between D and Objective-C :
>
> * The D compiler does not support any form of ARC, it's back to 
> using retain/release
>
> * When allocating memory with the GC in D and passing it to 
> Objective-C (or C for that matter) you have to make sure there 
> is still a root pointing to the memory. This can either be a 
> variable that is still in scope or by explicitly adding a new 
> root by calling core.GC.addRoot.
>
> I don't know if any of the above is the actual problem, but it 
> could be. I would recommend trying to contact Michel Fortin how 
> original implemented D/Objective-C.
>
> BTW, There is a tool, DStep [1], that can automatically 
> generate bindings for Objective-C code.

Hey Jacob, thanks very much for your reply! It is of course this 
NSMutableArray that stores the custom objects containing 
NSString's and an NSImage, which gets deallocated after some time 
(still can see some garbage if I make it a static member). I will 
try to figure out how to use retain and release, I once knew how 
to do this quite well, but since ARC I quit to worry ;) Thanks 
for the core.GC.addRoot tip!

DStep was not very helpful when I tried it, it wanted to find all 
the referenced includes, which of course can be quite complicated 
when trying to get foundation and appkit headers processed.

Once this ARC / memory management stuff is resolved, d-objc on 
OSX will be super awesome!! Thanks to you and Michel for all the 
work!





More information about the Digitalmars-d-announce mailing list