Objective-C 2.0 on FreeBSD; garbage collection, anyone?
Nerius Landys
nlandys at gmail.com
Thu Mar 11 06:53:53 UTC 2010
> What is the content of the header file?
File GarbageObj.h:
====================
#import <Foundation/Foundation.h>
@interface GarbageObj : NSObject {
}
-(void) foo;
@end
File GarbageObj.m:
====================
#import "GarbageObj.h"
@implementation GarbageObj
-(void) foo {
}
-(void) dealloc {
//printf("dealloc\n");
[super dealloc];
}
@end
File GarbageMain.m:
====================
#import "GarbageObj.h"
int main(int argc, const char *argv[]) {
int inx = 0;
while (YES) {
inx++;
GarbageObj *obj = [[GarbageObj alloc] init];
[obj foo];
if (inx == 1000000) {
inx = 0;
sleep(1);
}
//printf("before release\n");
//[obj release];
//printf("after release\n");
}
return 0;
}
File GNUmakefile:
====================
include $(GNUSTEP_MAKEFILES)/common.make
APP_NAME = garbagecollection
garbagecollection_HEADERS = GarbageObj.h
garbagecollection_OBJC_FILES = GarbageObj.m GarbageMain.m
garbagecollection_RESOURCE_FILES =
ADDITIONAL_OBJCFLAGS = -fobjc-gc
include $(GNUSTEP_MAKEFILES)/application.make
(I was building it as a "tool" before but now I tried "app" instead.
Same thing really.)
More information about the freebsd-questions
mailing list