Note that there are some explanatory texts on larger screens.

plurals
  1. PONSScanner memory leak
    primarykey
    data
    text
    <p>I'm at my first experiences with iPhone development. I wrote some basic code to test the NSScanner class, and now I was looking into the Leaks tool. It seems that this code is leaking, when in the detailed stack I double-click my last call (before Apple's stuff), the incriminated line is the commented.</p> <p>Can anyone help me to understand why this is leaking? from a logical point of view the result is what I expect, and I do not formally alloc anything myself (except for the xmlblock variable, which is btw autoreleased), so I would not expect the need to release anything... where I'm wrong? :-)</p> <pre><code>+(NSSet *)extractXMLSectionsWithTag:(NSString *)tag fromString:(NSString *)source firstOnly:(BOOL)firstOnly { if (!source) return nil; NSScanner *scanner = [NSScanner scannerWithString:source]; NSString *openingToken = [NSString stringWithFormat:@"&lt;%@", tag]; NSString *closingToken = [NSString stringWithFormat:@"&lt;/%@&gt;", tag]; NSMutableSet *sections = [NSMutableSet set]; NSCharacterSet *majorChar = [NSCharacterSet characterSetWithCharactersInString:@"&gt;"]; while (![scanner isAtEnd]) { NSString *xmlBlock = [[[NSString alloc] init] autorelease]; [scanner scanUpToString:openingToken intoString:NULL]; [scanner scanString:openingToken intoString:NULL]; [scanner scanUpToCharactersFromSet:majorChar intoString:NULL]; [scanner scanCharactersFromSet:majorChar intoString:NULL]; [scanner scanUpToString:closingToken intoString:&amp;xmlBlock]; if (![xmlBlock isEqualToString:@""]) { // Leaking line [sections addObject:xmlBlock]; if (firstOnly) { break; } } } return [sections copy]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload