Date: Wed, 10 Mar 2010 01:00:59 -0800 From: Nerius Landys <nlandys@gmail.com> To: FreeBSD Mailing List <freebsd-questions@freebsd.org> Subject: Objective-C 2.0 on FreeBSD; garbage collection, anyone? Message-ID: <560f92641003100100y6490cf3veb53ca0b11a90dcb@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Running FreeBSD 8.0 32 bit PAE kernel, latest ports. My current hobby is to experiment more with Objective-C. I'm rewriting some of my old Java code in Objectve-C to get a better feeling for how this language works. I'm finally able to write, compile, and run Objective-C programs after learning about this the whole day. i noticed that the gcc42 compiler from ports is necessary as it contains the parts that are able to compile Objective-C. I realized that gcc43, gcc44, and gcc45 from ports are _not_ able to compile Objective-C. So my real question is this. The supposed feature called "garbage collection" that eliminates the need for "retain" and "release" syntax in Objective-C - has anyone gotten it to work? Frankly, I'm not even sure if Objective-C framework on my FreeBSD server is supporting Objective-C 2.0 or an older version; I have not gotten as far as knowing which language constructs exist in 2.0 but not in earlier versions. But for right now I'm just trying to get automatic garbage collection to work, which I know is a new feature in 2.0. So, I've written a simple program that instantiates objects over and over again, and loses references to them. Like so: #import "GarbageObj.h" int main(int argc, const char *argv[]) { while (YES) { GarbageObj *obj = [[GarbageObj alloc] init]; [obj foo]; // foo is does literally nothing. } return 0; } I am compiling this program and running it, and without the "release" calls there, it certainly is using up more and more memory every second. Definitely no garbage collection happening. I then modified the GNUmakefile to make sure that the option "-fobjc-gc" was being passed to gcc, and verbose output from make assured me that this was the case. However, my program sill did not garbage collect (3 gigs of RAM, then a segfault). I then tried the gcc option "-fobjc-gc-only" and gcc42 reported that it did not recognize that option. The options are described here: http://developer.apple.com/mac/library/documentation/DeveloperTools/gcc-4.0.1/gcc/Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html . So, I can't really try the newer compilers from ports because they don't do Objective-C, and even so, I don't know if that would have any effect on garbage collection. Has anyone had success in writing Objectve-C programs on FreeBSD that have automated garbage collection? Does anyone know if this is Objective-C 2.0 I'm dealing with? How do I get this to work? For reference, here is a diff of packages installed today as a result of trying out Objective-C: > aspell-0.60.6_2:textproc/aspell > cups-client-1.4.2_4:print/cups-client > ffcall-1.10_1:devel/ffcall > fontconfig-2.8.0,1:x11-fonts/fontconfig > gcc-4.2.5.20090325_2:lang/gcc42 > giflib-nox11-4.1.6:graphics/giflib > gnustep-back-0.17.1_1:x11-toolkits/gnustep-back > gnustep-base-1.19.3:lang/gnustep-base > gnustep-gui-0.17.1_1:x11-toolkits/gnustep-gui > gnustep-make-2.2.0_1:devel/gnustep-make > gnutls-2.8.3:security/gnutls > jbigkit-1.6:graphics/jbigkit > libXft-2.1.14:x11-fonts/libXft > libXrender-0.9.4_1:x11/libXrender > libaudiofile-0.2.6_1:audio/libaudiofile > libgmp-4.3.2:math/libgmp4 > mpfr-2.4.2:math/mpfr > portaudio-19.20071207:audio/portaudio2 > renderproto-0.9.3:x11/renderproto > tiff-3.9.2_1:graphics/tiff - Nerius
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?560f92641003100100y6490cf3veb53ca0b11a90dcb>