Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

happybob

macrumors newbie
Original poster
Apr 18, 2009
17
0
Hi,

I have one final 3.5 kb memory leak that's driving me insane. It's resulting from a thread not being exited before the view is released. The following is how I created the thread, what I'm looking for is a command like [something exit] or [something cancel] that will exit the thread right before the view is released. Thanks for the help.

Code:
   // Created Using the following
[NSThread detachNewThreadSelector:@selector(changeColor) toTarget:self withObject:nil];

-(void) changeColor {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

//Actions

[pool release];
}
 

happybob

macrumors newbie
Original poster
Apr 18, 2009
17
0
Actually I tried that by defining altThread in the header

Code:
NSThread *tempThread = [NSThread detachNewThreadSelector:@selector(changeColor) toTarget:self withObject:nil];

altThread = tempThread

Then I used the [altThread exit]; where I wanted it to exit.

The problem was that I received an error "void value not ignored as it ought to be. So I tried a few other ways to create threads and either got warnings which crashed the app or an app that no longer worked as the thread no longer did what it was supposed to.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
detachNewThreadSelector:toTarget:withObject: returns void. If you want to store a reference to the NSThread object you need to use one of the init methods provided instead.
 

beon

macrumors newbie
Sep 25, 2008
10
0
LA CA
Solution?

Anyone find a solution to this one? I'm honing in on it myself, and it'd be a big help if it were here for future trekkers.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.