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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:28:35+00:00 2026-05-24T17:28:35+00:00

Possible Duplicate: iPhone SDK:How can I fix this leakage? This question is different from

  • 0

Possible Duplicate:
iPhone SDK:How can I fix this leakage?

This question is different from the previous one, even it is in the same class,

I have a leakage as below,

@property (nonatomic,retain) NSMutableData *responseXMLData;
@property (nonatomic,copy) NSMutableData *lastLoadedResponseXMLData;

-(void)dealloc {
[doc release];
doc=nil;
[xmlBodyTemp release];
[responseXMLData release] ;
responseXMLData=nil;
[lastLoadedResponseXMLData release];
lastLoadedResponseXMLData=nil;
[xmlBody release];
[super dealloc];
}

enter image description here

Second question: in the variables given above when I write:

self.responseXMLData = [self.lastLoadedResponseXMLData copy];

Do I need to release self.lastLoadedResponseXMLData once more other than I did in dellaoc? or only delloc is eneough? autorelease seems to work but didnt get the idea why

  • 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-24T17:28:36+00:00Added an answer on May 24, 2026 at 5:28 pm

    I highly recommend that you read through the Memory Management Programming Guide that Apple has provided. This will give you a better understanding of how to better manage your allocations.

    —

    IMO (not sure others will agree), all you need to do in dealloc is release your objects. There’s no need to set them to nil.

    You need to release the object that you’re copying. When you copy[1] something, the retain count is incremented by 1. Then when you assign it to self.responseXMLData, the retain count is incremented by 1 again (since the property does a retain). The best thing to do here would be to autorelease it. [[self.lastLoadedResponseXMLData copy]autorelease];

    [1] The simplest rule of thumb is that any time you alloc, copy, new, or retain something, you own it, and you’re responsible for releasing it in the scope in which you took ownership.

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

Sidebar

Related Questions

No related questions found

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.