• 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: Memory allocation issues with NSObject and NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory allocation issues with NSObject and NSString


  • Subject: Re: Memory allocation issues with NSObject and NSString
  • From: Chris Suter <email@hidden>
  • Date: Mon, 19 Jan 2009 15:52:32 +1100

Hi Bill,

On Mon, Jan 19, 2009 at 3:21 PM, Bill Bumgarner <email@hidden> wrote:

> foo = @""; // foo is a reference to the empty string
> foo = [[NSString alloc] init]; // foo is a reference to the empty string
>
> The second is retained.  The first is not.  The first is a constant string
> and, thus, -retain/-release is a no-op.  An implementation detail to ignore:
>
> foo = [@"" retain];

Are you sure about that? My understanding is that the second case ends
up pointing to a constant string and that retain and release are also
no-ops in that case.

Also, if I remember rightly, that in the first case you'll end up
pointing to a constant in the current translation unit, whereas in the
second case you end up pointing to a global constant defined in
CoreFoundation. Implementation details, I know.

Regards,

Chris
_______________________________________________

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: Memory allocation issues with NSObject and NSString
      • From: Bill Bumgarner <email@hidden>
References: 
 >Memory allocation issues with NSObject and NSString (From: "Devraj Mukherjee" <email@hidden>)
 >Re: Memory allocation issues with NSObject and NSString (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: File association
  • Next by Date: Re: bindings and sub array modification notification.
  • Previous by thread: Re: Memory allocation issues with NSObject and NSString
  • Next by thread: Re: Memory allocation issues with NSObject and NSString
  • Index(es):
    • Date
    • Thread