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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:27:25+00:00 2026-05-19T09:27:25+00:00

am writing an application that parses some xml and creates a dictionary of the

  • 0

am writing an application that parses some xml and creates a dictionary of the element names and their values using the below key methods:

- (void)parserDidStartDocument:(NSXMLParser *)parser{
    foundCharacters = [[NSMutableString alloc] init];
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { 
    if (accumulator) {
        [foundCharacters appendString:string];
    }
} 

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

    if ([foundCharacters length] != 0) {

                    [parsedContent setObject:[foundCharacters copy] forKey:elementName];

                }
}

The leak occurs in the occurs on the “[parsedContent setObject:[foundCharacters copy] forKey:elementName];” line, I can’t work out a way to overcome this.

Any insights would be much appreciated.

Edit:

The memory leak only occurs if the request to parse is called more than once

I’ve also tried “[[foundCharacters copy] autorelease]” but no to avale

  • 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-19T09:27:25+00:00Added an answer on May 19, 2026 at 9:27 am

    In your parserDidStartDocument: you alloc/init a mutable string, but I don’t see code where you dispose of this string again. You need to release the string again, for example in the parserDidEndDocument: method.

    The memory leak is reported later probably because this is the last place where the variable was actually referenced.

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

Sidebar

Related Questions

I am writing an application in Java for Android (SDK v8) that parses XML
I'm writing a Java GUI application that is doing some XML parsing and analysis.
I am writing an application that parses n number of records each with m
I'm writing an application that takes HTML pages and parses them to display on
I'm writing a simple application that will read some records and insert them in
I am writing a .net application that is taking form information to do some
I'm writing an application that listens for sound events (using messages passed in with
Im writing an application that supposed to send coordinates in an SMS, but I've
I am writing an application that allows a user to place images on a
I am writing an application that will allow an android phone and java application

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.