From owner-freebsd-questions@FreeBSD.ORG Wed Mar 10 09:01:01 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 893E21065678 for ; Wed, 10 Mar 2010 09:01:01 +0000 (UTC) (envelope-from nlandys@gmail.com) Received: from mail-qy0-f183.google.com (mail-qy0-f183.google.com [209.85.221.183]) by mx1.freebsd.org (Postfix) with ESMTP id 47B0A8FC15 for ; Wed, 10 Mar 2010 09:01:01 +0000 (UTC) Received: by qyk14 with SMTP id 14so3182851qyk.9 for ; Wed, 10 Mar 2010 01:01:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=k77NKwHmgh5JIo5kbszK3bxFhxvoLAtYL4isX6rPOkI=; b=t7/uGF6qIqlbQuo2+XeC0eIz6x0DbGtT6rYR36CtL8MTnBXmPXbSqwpBz17XuBBuPD rj1MOgfkjCCEL1ZKuIjd7rUol3WQsolq5/XrrW3tpR31O9Ct62qJzDjZwm5AtItX2npq NjcISXO5fCjzXm2hB109uDeJShRyZ7VlZrf1I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=KqmdboTBZKaaIxpEc5+Xjbs/LyWeiAG6qaKtYb5VD0iSwiH6vQiFxec0LKkTlWQbHO X2lp3CS/ZYOdRldren2g0BKVheQQ+UXBgXiCR1aZNJ2LFD6wArOVc8Q4KDLf/ZjMue6y VJNl3+pIACkn/MB5cOos1rv1OW82/tiY7e9Pg= MIME-Version: 1.0 Received: by 10.229.44.5 with SMTP id y5mr1186372qce.11.1268211659121; Wed, 10 Mar 2010 01:00:59 -0800 (PST) Date: Wed, 10 Mar 2010 01:00:59 -0800 Message-ID: <560f92641003100100y6490cf3veb53ca0b11a90dcb@mail.gmail.com> From: Nerius Landys To: FreeBSD Mailing List Content-Type: text/plain; charset=ISO-8859-1 Subject: Objective-C 2.0 on FreeBSD; garbage collection, anyone? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Mar 2010 09:01:01 -0000 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