Why do game programmers hate high level languages

Unity C# and regular C# work the same if talk about memory management and garbage collection. There are no differences between them in this matter.

There may be some additional constraints by Unity engine, like when you are allowed and how you need to allocate objects, I don't know about that.

As for ARC - yes, it is by default on for latest Xcode projects. If Xcode project is created long time ago, it may have ARC turned off. ObjectiveC ARC is not really a garbage collector. It is reference counting. It can be used to implement garbage collection. But by itself it is more like std::shared_ptr in C++, but with more help from compiler.

Edited by Mārtiņš Možeiko on
I don't know if you tried Unity C# on a OSX. It seems like if wrote the code above, it would work and not cause a crash in MVS C#. I'm not sure.
Objective C for OS X doesn't have garbage collection; it's been deprecated for a long time now and I believe is now completely removed.

Objective C for iOS never had garbage collection.

ARC is automatic reference counting; it inserts all of the retain and releases in your code because it understands the Cocoa API and all of the naming conventions regarding memory rules. This can lead to slower code in some cases as the needs to insert additional retain/release calls to ensure safety. ARC is not a garbage collector in the normal sense of the word; it's an automated reference counting system.

Garbage collectors do not remove objects in memory that still have a handle to them. You simply have a coding error, as others have mentioned.

Also, the property semantics (weak, strong, copy, etc...) are only metadata to tell the compiler how to generate the setter/getter methods for properties. If you are setting the raw field yourself, you need to handle things properly. It seems like this is where some of the issues in your ObjC code may be coming from.
I might have some errors in my Objective C code but I'm not sure about my Cocos2D 2.(insert long number here) code which uses C++ and not Objective C but the method is taken from Objective C. I'm not a big fan of ARC or Garbage Collection, I'll rather find an efficient way to hand it myself.