Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6816693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:57:23+00:00 2026-05-26T20:57:23+00:00

In ARC, does it create a memory leak to alloc into a @property (strong)

  • 0

In ARC, does it create a memory leak to alloc into a @property (strong)

// MyClass.h
@property (strong) NSString *myString;

// MyClass.m
@synthesize myString=_myString;

- (void)viewDidLoad
{
    self.myString = [[NSString alloc] initWithFormat:@"Test %@", otherString];
}

I know that in manual memory management, the equivalent would create a leak

// MyClass.h
@property (retain) NSString *myString;

// MyClass.m
@synthesize myString=_myString;

- (void)viewDidLoad
{
    self.myString = [[NSString alloc] initWithFormat:@"Test %@", otherString];
}

- (void)dealloc
{
    [_myString release];
}

Is ARC able to handle the top example correctly? Does it optimize away one of the retains? Or maybe release twice in the dealloc?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:57:23+00:00Added an answer on May 26, 2026 at 8:57 pm

    This is perfectly valid under ARC.

    I would recommend reading the ARC documentation to get more comfortable with trusting what it has to offer. http://clang.llvm.org/docs/AutomaticReferenceCounting.html and Mike Ash has a great blog post on how it works http://www.mikeash.com/pyblog/friday-qa-2011-09-30-automatic-reference-counting.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using ARC for iOS, is there any difference between the following? @property (strong,
I create a new project using xcode4.2, and view the AppDelegate: @property (strong, nonatomic)
Does anyone know how to define an animated arc / circle in SVG, such
I'm trying to use TPMultiLayoutViewController in a project using ARC, but am bumping into
Hi I have a nasty memory management issue under ARC and cannot figure out
With all this new ARC stuff (which does not fall under NDA…) coming out,
My app, which uses ARC, does the following: Uploads a picture taken by the
In my interface (.h) file, I have @property(readonly) NSString *foo; and in my implementation
I create a simple circle with the arc function: /* ctx is the 2d
I am trying to draw an arc. But nothing is drawn? - (void)viewDidLoad {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.