NSThread, NSAutoreleasePool and mach_trap_msg
NSThread, NSAutoreleasePool and mach_trap_msg
- Subject: NSThread, NSAutoreleasePool and mach_trap_msg
- From: Georg Schuster <email@hidden>
- Date: Wed, 18 Jun 2008 20:10:48 +0200
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 (email@hidden)
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:
This email sent to email@hidden