• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Memory Management for XML Parsing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory Management for XML Parsing


  • Subject: Memory Management for XML Parsing
  • From: Bing Li <email@hidden>
  • Date: Sun, 12 Jun 2011 17:44:03 +0800

Dear all,

I got another memory management problem. When an XML is received, it must be
parsed using the below method. When a large number of XML is received, the
receiver's memory is increased slowly. I tried to figure out where the
memory leaks. I guess the method might cause this problem.

The NSArray, nodes, is created by xmlDoc. Since the method is not the owner,
nodes should be released here. One value of the array must be returned. Does
the value leak? The method below is correct?

Thanks so much for your help!

Best regards,
Bing

+ (NSString *)read:(NSString *)xml Path:(NSString *)xPath
{
        NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithXMLString:xml
options:NSXMLDocumentTidyXML error:NULL];
        NSArray *nodes = [xmlDoc nodesForXPath:xPath error:NULL];
        [xmlDoc release];
        if ([nodes count] > 0)
        {
                return [[nodes objectAtIndex:0] stringValue];
        }
        else
        {
                return Constants.WWW.EMPTY_STRING;
        }
}
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Memory Management for XML Parsing
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Why Wasn't Memory Collected?
  • Next by Date: Re: Getting CGColor components
  • Previous by thread: Re: layoutSubviews doesn't always work (iOS 4.3 on iPad Simulator)
  • Next by thread: Re: Memory Management for XML Parsing
  • Index(es):
    • Date
    • Thread