Unless I misread the documentation on drain, adding a [pool drain]will
cause the pool to be deallocated.  I tried it anyways, and I get a couple
of emits in the console.

// This message emits when a call to the getter is made
2011-05-21 20:23:39.515 LeakyThread[5947:5707] ***
__NSAutoreleaseNoPool(): Object 0x10011d720 of class NSCFString
autoreleased with no pool in place - just leaking

// This message emits when a call to pool drain is called.
2011-05-21 20:23:39.515 LeakyThread[5947:5707] *** -[NSAutoreleasePool
drain]: This pool has already been drained, do not release it (double
release).


Still not sure what the problem is.
Tony Romano



On 5/21/11 6:58 PM, "Ken Thomases" <k...@codeweavers.com> wrote:

>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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to