Re: [Leaking] Need Help With Creating NSMutableNumber Class
Re: [Leaking] Need Help With Creating NSMutableNumber Class
- Subject: Re: [Leaking] Need Help With Creating NSMutableNumber Class
- From: Chase <email@hidden>
- Date: Tue, 12 Jul 2005 00:14:39 -0500
On Jul 11, 2005, at 12:12 PM, Bill Bumgarner wrote:
On Jul 11, 2005, at 4:56 AM, Chase wrote:
+ (XXXMutableNumber *)numberWithBool:(BOOL)value {
return [[[XXXMutableNumber alloc] initWithBool:value]
autorelease];
}
That is correct.
hmmm... something's got to be wrong though. it appears that nothing
is actually getting added to the autorelease pool.
i added a little NSLog() statement to the dealloc method for testing:
- (void)dealloc {
NSLog(@"dealloc %@", [self stringValue]);
[_number release];
[super dealloc];
}
... and added the following code to applicationDidFinishLaunching:
- (void)applicationDidFinishLaunching:(NSNotification *)
aNotification {
XXXMutableNumber * testnum1 = [[XXXMutableNumber alloc]
initWithInt:123];
NSLog(@"using %@", [testnum1 stringValue]);
[testnum1 release];
XXXMutableNumber * testnum2 = [XXXMutableNumber
numberWithInt:456];
NSLog(@"using %@", [testnum2 stringValue]);
NSLog(@"...");
NSLog(@"...");
NSLog(@"...");
}
... which results in the following output:
2005-07-11 23:39:48.593 MEMTEST[5362] using 123
2005-07-11 23:39:48.593 MEMTEST[5362] dealloc 123
2005-07-11 23:39:48.593 MEMTEST[5362] Using testnum2 : 456
2005-07-11 23:39:48.732 MEMTEST[5362] ...
2005-07-11 23:39:48.738 MEMTEST[5362] ...
2005-07-11 23:39:48.742 MEMTEST[5362] ...
... which is wrong, because testnum2 ("456") doesn't get dealloced at
the end of the calling context as it should.
the bottom line is that it appears that the following code, for
whatever reason, is not actually adding anything to the autorelease
pool of the calling context:
+ (XXXMutableNumber *)numberWithInt:(int)value {
return [[[XXXMutableNumber alloc] initWithInt:value]
autorelease];
}
... but why?
- chase
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden