• 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: Why I have a leak? I am unable to understand
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why I have a leak? I am unable to understand


  • Subject: Re: Why I have a leak? I am unable to understand
  • From: "Hank Heijink (Mailinglists)" <email@hidden>
  • Date: Mon, 24 Aug 2009 20:28:05 -0400

On Aug 24, 2009, at 8:20 PM, Agha Khan wrote:

HI:

I know the leak is in next 2 lines
I have commented all the code except these 2 lines.

// NSTimeInterval
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents *dateSegments = [gregorian components:unitFlags fromDate:[NSDate date]];


I am not releasing gregorian, because I never used retain.
Same is true with dateSegments.

You'll have to reread the memory management guide.

http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html

You created gregorian using alloc + init, therefore you own it and you do need to release it.

Hank

_______________________________________________

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: 
 >Why I have a leak? I am unable to understand (From: Agha Khan <email@hidden>)

  • Prev by Date: Re: Why I have a leak? I am unable to understand
  • Next by Date: Re: NSTableView and programmatic changing of contextual menu
  • Previous by thread: Re: Why I have a leak? I am unable to understand
  • Next by thread: NSTableView and programmatic changing of contextual menu
  • Index(es):
    • Date
    • Thread