• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSThread, NSAutoreleasePool and mach_trap_msg
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSThread, NSAutoreleasePool and mach_trap_msg
      • From: Bill Bumgarner <email@hidden>
  • Prev by Date: Re: Race condition with awakeFromNib?
  • Next by Date: NSKeyedArchiver finishEncoding takes forever
  • Previous by thread: Re: Swapping splitview subviews
  • Next by thread: Re: NSThread, NSAutoreleasePool and mach_trap_msg
  • Index(es):
    • Date
    • Thread