Hi,

as I'm fairly new to cocoa-programming, I've stumbled across a problem that I can't quite understand. - I've made a class (let's call it ThreadClass) that is a subclass of NSThread. - This class gets invoked from somewhere else via [theThreadClass start].
        - That invokes ThreadClass's -(void)main
I read the documentation for NSThread and I do understand why you have to create an autoreleasepool (at least I hope), so I created one.

The Problem is now the following: I got another class (let's call it WorkerClass). And in the ThreadClass, I want to do the following:

- (void)main {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        
        WorkerClass *wc = [[WorkerClass alloc] init];
        [wc doStuff];

        [pool release];
}

When I compile this, the program runs up to this point and then crashes with a "mach_trap_msg". If I leave out the AutoreleasePool, everything works fine, but the program is leaking memory, which is obviously not an option. I found out that if I comment out the [wc doStuff], everything compiles fine.

I'm sorry that I can't post any real code, but does anybody know if there are some special things I should keep an eye on when programming the WorkerClass? I tried to read every doc about threads and autoreleasepools I could get my hands on (including the apple-docs), but I just can't find any solution to get rid of that kernel trap message.

Any help would be greatly appreciated.

Best regards,

  Georg Schuster
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to