Re: NSCFNumber, no pool in place - just leaking
Re: NSCFNumber, no pool in place - just leaking
- Subject: Re: NSCFNumber, no pool in place - just leaking
- From: Craig Bakalian <email@hidden>
- Date: Tue, 24 Dec 2002 03:09:05 -0500
Hi Roarke Lynch,
Right! This is wild stuff. When I added the clearToneFromTones:
(unsigned)toneValue method things got really wonky. So, oddly, just
leaving the autoreleasePool in the method without calling release
calmed the leaks. I still don't know if I am leaking... I gotta read
more about this. But, this works->
-(void)addToneToTones: (unsigned)toneValue
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSNumber *n = [NSNumber numberWithUnsignedInt: toneValue];
[tones addObject: n];
}
-(void)clearToneFromTones: (unsigned)toneValue
{
NSAutoreleasePool *deletePool = [[NSAutoreleasePool alloc]init];
[tones removeLastObject];
}
If you know of a better way to clean up after this let me know. When
the user presses a midi keyboard key down a tone is added to a chord
array called tones, when the key goes up the chord is cleared. I am
expediting with removeLastObject. It is a music notation app, so the
chord must be cleared for the next write to view.
Craig Bakalian
On Monday, December 23, 2002, at 05:34 PM, Roarke Lynch wrote:
>
>
On Monday, December 23, 2002, at 03:55 PM, Craig Bakalian wrote:
>
>
> -(void)addToneToTones: (unsigned)toneValue
>
> {
>
> NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>
> NSNumber *n = [NSNumber numberWithUnsignedInt: toneValue];
>
> [tones addObject: n];
>
> [n release];
>
> [pool release];
>
> }
>
>
You might get another error here. You are calling release on an
>
object that should already be autoreleased. More to the point, by
>
creating n without an alloc/init call, but still releasing it, you are
>
violating the alloc/retain <-> autorelease/release balance within the
>
method.
>
>
Roarke Lynch
>
-------------------------------
>
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.