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 6008407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:49:10+00:00 2026-05-23T01:49:10+00:00

In my app i get a memory leak in first -(void)connectionDidFinishLoading:(NSURLConnection *)connection { result

  • 0

In my app i get a memory leak in

first

-(void)connectionDidFinishLoading:(NSURLConnection *)connection {  
    result = [[NSString alloc] initWithBytes:[webData mutableBytes]
                                      length:[webData length]
                                    encoding:NSUTF8StringEncoding];  
    [webData release];  
}

second

-(void)connectionDidFinishLoading:(NSURLConnection *)connection {  
    NSString * result = [[NSString alloc] initWithBytes:[webData mutableBytes]
                                                 length:[webData length]
                                               encoding:NSUTF8StringEncoding];
    [webData release];
}

in my first process I didn’t get a memory leak(Declare a string object globally and I didn’t release it)

In my second process i get a memory leak in string object.

  1. Value stored to ‘result’ during its initialization is never read

  2. Method returns an Objective-C object with a +1 retain count (owning reference)

  3. Object allocated on line 124 and stored into ‘result’ is no longer referenced after this point and has a retain count of +1 (object leaked)

what is the difference?

  • 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-23T01:49:11+00:00Added an answer on May 23, 2026 at 1:49 am

    In first case analyzer expects you to release your initted result string in, say, - (void)dealloc method of the class. If you don’t – you’ll get a leak as well (you’ll see the leak if you run your app with via Instruments app with Leaks instrument added.

    In second case you’re creating a local variable in method scope where it should be released as well since you won’t have a reference of it in any other method (i.e. if you try access result variable in other method you’ll get unknown identifier error).

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

Sidebar

Related Questions

I'm currently hunting down a memory leak in my app for iPhone. I'm using
I desperately need help with a memory leak in my iPhone app. The app
Why is the following code causing a memory leak in an iPhone App? All
I have a WindowsForms app that appears to leak memory, so I used Redgate's
When I do an analyze in xcode, I get this memory leak on the
I think that I have a memory leak in my app witch I can't
I wanted to do some Memory-Leak tracking on my App, but somehow I am
I have troubles finding a memory leak which then again causes my App to
How can my app get a valid last time connected to domain timestamp from
I am just testing an app to get data off our web server, previously

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.