• 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
Will this leak memory?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Will this leak memory?


  • Subject: Will this leak memory?
  • From: Neil Earnshaw <email@hidden>
  • Date: Fri, 5 Sep 2003 14:36:48 +0100

Will this implementation of the Singleton pattern leak memory in Obj-C?

+(id)defaultObject
{
static MyObject* defaultObject;

if ( !defaultObject ) {
defaultObject = [[MyObject alloc] init];
}
return defaultObject;
}

-(void)dealloc
{
NSLog(@"%@ dealloc",self);
...
[super dealloc];
}

The dealloc log message never gets called.

-Neil

Neil Earnshaw
Consultant Software Engineer
Object Software Engineers Ltd
email@hidden
Tel : 01747 854 852
Mbl : 07870 209 102
_______________________________________________
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: Will this leak memory?
      • From: Neil Earnshaw <email@hidden>
    • RE: Will this leak memory?
      • From: "Jonathan E. Jackel" <email@hidden>
    • Re: Will this leak memory?
      • From: "Alastair J.Houghton" <email@hidden>
    • Re: Will this leak memory?
      • From: Chris Ridd <email@hidden>
    • Re: Will this leak memory?
      • From: lbland <email@hidden>
    • Re: Will this leak memory?
      • From: j o a r <email@hidden>
  • Prev by Date: Re: Controlling the Open Recent menu
  • Next by Date: Re: Newbie Question about documentation
  • Previous by thread: Re: Newbie Question about documentation
  • Next by thread: Re: Will this leak memory?
  • Index(es):
    • Date
    • Thread