• 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: NSDate appears to leak
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDate appears to leak


  • Subject: Re: NSDate appears to leak
  • From: Lloyd Sargent <email@hidden>
  • Date: Wed, 21 Nov 2007 15:50:14 -0600


On Nov 21, 2007, at 1:11 PM, Shawn Erickson wrote:

On Nov 21, 2007 10:51 AM, Lloyd Sargent wrote:
I'm trying to track down a problem on 10.4.11 using MallocDebug. When
I had tested this with 10.4.10 I don't think I had this problem, but
now I get the following:

This is the code that is causing said leak:

- (void) userThread: (id) param
{

     //----- create the autorelease pool so we don't leak
     NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];

     sleep(10);

     while (1)
     {
          [[NSRunLoop currentRunLoop] runUntilDate: [NSDate
dateWithTimeIntervalSinceNow: 1]];
     }

     [localPool release];
}

Or is MallocDebug making me chase my tail?

Not sure but the above code is filling up an autorelease pool with temporary objects... your loop makes no attempt to manage an autorelease pool.

Yup... that was the problem. Changed the code to the following:

- (void) userThread: (id) param
{
//----- create the autorelease pool so we don't leak
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];

sleep(10);

while (1)
{
NSAutoreleasePool *mylocalPool = [[NSAutoreleasePool alloc] init];
[[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1]];
[mylocalPool release];
}

[localPool release];
}


Seems to have fixed the unit testing code...

Cheers,

Lloyd
_______________________________________________

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


References: 
 >NSDate appears to leak (From: Lloyd Sargent <email@hidden>)
 >Re: NSDate appears to leak (From: "Shawn Erickson" <email@hidden>)

  • Prev by Date: Re: CoverFlow
  • Next by Date: Re: replacing NSViewAnimation with CoreAnimation
  • Previous by thread: Re: NSDate appears to leak
  • Next by thread: Re: NSDate appears to leak
  • Index(es):
    • Date
    • Thread