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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:08:27+00:00 2026-05-13T14:08:27+00:00

I use NSXMLParser for parsing an XML document. I have the following functions (among

  • 0

I use NSXMLParser for parsing an XML document. I have the following functions (among others):

- (void) parserDidStartDocument:(NSXMLParser *)parser {

    // Init tempString
    tempString = [NSMutableString string];

}    
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

        // save gained data for element "date"
        if ([elementName isEqualToString:@"date"])
            [entryDict setObject:[tempString copy] forKey:kXMLDictDateKey];

        [tempString setString:@""];
    }


    //
    // Character Handling
    //
    - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
        [tempString appendString:[[XMLParser alloc] stripUnwantedStringChars:string]]; //Just strips tabs and linebreaks and the returns the string
    }

tempString is an instance variable with the following property:

@property (nonatomic, retain) NSMutableString *tempString;

tempString does not have to be released in dealloc as it is initiated with a convenience method, thus it is automatically assigned to an autorelease pool. I have also tried the following with an alloc, init approach, yet with the same result. So here is what I did:

1.) Run my project with instruments, let it search for leaks right after startup, there are none.
2.) run the XML parser once, check for leaks. There are none.
3.) run the XML Parser again, now suddenly the line with [entryDict setObject:[tempString copy] forKey:kXMLDictDateKey]; leaked.

I have been looking into these memory leaks for hours now, what did I forget? If you need more code please let me know, although I think my problem is somewhere in these lines.

Ps. My checks show that between the parser (delegate) calls the “dealloc” method gets called, thus I think the parser is really loaded two times, not just once.

  • 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-13T14:08:27+00:00Added an answer on May 13, 2026 at 2:08 pm

    Your call to:

    tempString = [NSMutableString string];
    

    Actually does not invoke the property (wrapper) and the retain.

    You should do this instead:

    self.tempString = [NSMutableString string];
    

    Otherwise you are just setting the ivar directly to an autoreleased object.

    Not only do you have a leak somewhere, the above code will at one point result in some interesting crash.

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

Sidebar

Related Questions

Should I use initWithURL or NSRequest to download an XML file when using NSXMLParser
I have a application, what is download a xml file and after parser it.
I have a xml file. That I want to parse with NXXMLParser. I have
I use an NSXMLParser to parse YouTube's API and I get all the content
I'm learning to use the NSXMLParser API for the iOS platform and so far
use case: 5 - 30 users simultaniously on a chat. is it a good
USE [Fk_Test2] GO /****** Object: Table [dbo].[Owners] Script Date: 08/20/2010 16:52:44 ******/ SET ANSI_NULLS
Use of rails 3 recaptcha. In view _form.html.erb insert <%= recaptcha_tags %> But when
I am stuck in a strange situation , i am getting data from the
I try to find out why my app crashes (RSS Reader) if I send

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.