0

I am using TBXML to parse XML files from an url and I have ARC on. But I got memory leak for the following code:

- (void)readXmlFromUrl:(NSString*)url
{
    NSURL *aUrl = [NSURL URLWithString:url];
    NSData *data = [[NSData alloc] initWithContentsOfURL:aUrl];
    TBXML *tbxml = [[TBXML alloc] initWithXMLData:data];
//    data = nil;
//    NSLog(@"Reading from %@", url);
    // If TBXML found a root node, process element and iterate all children
    if (tbxml.rootXMLElement) {
        NSLog(@"Root Found");
        [self traverseElement:tbxml.rootXMLElement];
    }

//    data = nil;
//    aUrl = nil;
//    tbxml = nil;
//    NSLog(@"Retain count for TBXML %d", tbxml.retainCount);
}

I attached an image of memory leak. Thanks in advance enter image description here

Avigit
  • 284
  • 2
  • 3
  • 13

2 Answers2

1

Not a leak but likely a bug in the static analyzer.

Jon Shier
  • 12,200
  • 3
  • 35
  • 37
0

my answer was bogus didnt see you were using ARC

deleted_user
  • 3,817
  • 1
  • 18
  • 27