Objective-C / ARC / memory management issues were done to death on SO, but this seems a little different from the existing ones.
I am trying to use Objective-C with GNUStep and Clang. I loaded the libraries apparently required for modern Objective-C functions such as ARC; blocks and @autoreleasepool are accepted by the compiler along with the corresponding compiler flag. The AppKit GUI toolkit works as well as the queue manager.
My understanding, if correct, is that alloc ed objects are automatically configured to be freed when the "parent" stack frame is exited from @autoreleasepool , and this frees up the link count decrement. However, the compiler does not pay the [super dealloc] manual and allows the autoreleases and releases manual, which means that ARC is not even enabled.
It can be assumed that Googling GNUStep ARC ~enable will give some compiler flag, which I miss, but it is not.
Here is a sample code. This is a wrapper around an object around the multidimensional array C99 bool s, which is malloc ed in init and free d inside dealloc , which I collect is one of the few legitimate uses of dealloc in ARC code. Note that dealloc puts is called not , invoked after @autoreleasepool completes, even though it creates only one link. However, the release or autorelease works fine.
My compilation script (I will use the appropriate make file as soon as I can): -
#!/bin/sh INC_FLAG=`gnustep-config --variable=GNUSTEP_SYSTEM_HEADERS` LIB_FLAG=`gnustep-config --variable=GNUSTEP_SYSTEM_LIBRARIES` clang -o main main.m \ -I $INC_FLAG \ -L $LIB_FLAG \ \ -fblocks \ -fobj-arc \ -fconstant-string-class=NSConstantString \ -D_NATIVE_OBJC_EXCEPTIONS \ \ -pthread \ -lgnustep-base \ -ldispatch \ -lgnustep-gui \ -lobjc
I was on the assumption that autorelease should be inferred for objects created in @autoreleasepool .
Thanks in advance!
memory-management objective-c automatic-ref-counting autorelease gnustep
ljackman
source share