• 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
Re: NSCFNumber, no pool in place - just leaking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSCFNumber, no pool in place - just leaking


  • Subject: Re: NSCFNumber, no pool in place - just leaking
  • From: Craig Bakalian <email@hidden>
  • Date: Thu, 26 Dec 2002 14:30:11 -0500

Hi,
After much hacking, I think this is the best version. If anyone out
there know how to do this call from a standard C function in a better
way, or if anyone out there in Cocoa land thinks this thing is still
leaking, please let me know...

-(void)addToneToTones: (unsigned)toneValue
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSNumber *n = [[NSNumber alloc] initWithUnsignedInt: toneValue];
[tones addObject: n];
[n release];
[pool release];

}
-(void)clearToneFromTones: (unsigned)toneValue
{
NSAutoreleasePool *deletePool = [[NSAutoreleasePool alloc]init];
[tones removeLastObject];
[deletePool release];
}

in the clearToneFromTones I should check for toneValue before removing.

Craig Bakalian


On Tuesday, December 24, 2002, at 03:40 AM, David Rio Vierra wrote:

> Now you're not only leaking container objects, but also
> NSAutoreleasePools! Be sure to release the pool at the end of the
> function so that anything that got added to it also gets released.
> Remember - if you alloc it, you release it.
>
> - Rio
>
> On Monday, December 23, 2002, at 10:09 PM, Craig Bakalian wrote:
>
>> 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
_______________________________________________
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.

  • Follow-Ups:
    • Re: NSCFNumber, no pool in place - just leaking
      • From: MacInsight <email@hidden>
References: 
 >Re: NSCFNumber, no pool in place - just leaking (From: David Rio Vierra <email@hidden>)

  • Prev by Date: Re: Crontab/Scheduled tasks
  • Next by Date: Re: *Really* Understanding Cocoa
  • Previous by thread: Re: NSCFNumber, no pool in place - just leaking
  • Next by thread: Re: NSCFNumber, no pool in place - just leaking
  • Index(es):
    • Date
    • Thread