Search code examples
iosmemory-leaksxml-parsingkissxml

iOS XML Parser memory leaks with KissXML


I've been confused by this memory problem for a few days. In my iOS project, i use KissXML as XML parser. My XML files are huge(15M). Now, the memory problem comes:

Here's my code

http connection finished part:

NSData *copyData = [NSData dataWithData:self.httpData];  //self.httpData-recieved from http connection.
dispatch_async(globalQueue,^{  //globalQueue-GCD global queue.
    [AIDXMLParser universalParser:copyData];  //Class method for XML Parser.
});

In API:universalParser of AIDXMLParser.m

DDXMLDocument *doc = [[DDXMLDocument alloc] initWithData:xmlData options:0 error:nil];
[doc release];

When i run my app. I use [Activity Monitor] to catch my memory usage.

Before : [Real memory size] is 40.7M

After: [Real memory size is 63.1M

The increased memory (63.1M-40.7M) stays there forever.

Everything works well. I have tried using TBXML instead of KissXML. Use Instruments-Profile/Analyze for testing, but still no errors or no warnings. I don't know where i am wrong.

Is anybody else facing the same problem?


Solution

  • It might be because of the size of your NSData, try splitting your XML and do the parsing multiple time.

    I hade the same issue with JSON of 10MB+.