• 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: Synthesize getter in a NSThread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Synthesize getter in a NSThread


  • Subject: Re: Synthesize getter in a NSThread
  • From: Ken Thomases <email@hidden>
  • Date: Sat, 21 May 2011 20:58:36 -0500

On May 21, 2011, at 3:27 PM, Tony Romano wrote:

> I am running into an issue using a synthesized getter in a thread.
> Observing memory consumed by the application in Activity Monitor, memory
> continues to grow ~200k per sample until the OS gives an Out Of Memory
> warning.  If I code my own getter, the app behaves as expected.  I have
> striped it down to basically one call as follows:
>
> -(void) process:(LeakyThreadAppDelegate *) myDelegate
>
> {
>
> NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>
> // Extract the object that contains the thread object
>
> SomeClass *obj = [myDelegate myClass];
>
> NSLog(@"Thread Starting");
>
> // Simplified to illustrate the problem
>
> while (1) {
>
>
>
> if ([[obj thread] isCancelled] == YES) {
>
> break;
>
> }
>
> }
>
> NSLog(@"Thread Cancelled");
>
> [pool release];
>
> }
>
>
> Any clues as to what is wrong?  Thanks In Advance.

A synthesized getter is entitled to put objects into the autorelease pool.  The above code does not drain the pool until after the thread is cancelled.  Everything autoreleased before then just accumulates.  Try draining the pool each iteration of the loop.

Regards,
Ken

_______________________________________________

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: Synthesize getter in a NSThread
      • From: Tony Romano <email@hidden>
References: 
 >Synthesize getter in a NSThread (From: Tony Romano <email@hidden>)

  • Prev by Date: CVDisplayLink slows down execution of independent NSTimer
  • Next by Date: Re: Synthesize getter in a NSThread
  • Previous by thread: Synthesize getter in a NSThread
  • Next by thread: Re: Synthesize getter in a NSThread
  • Index(es):
    • Date
    • Thread