Note that there are some explanatory texts on larger screens.

plurals
  1. POAutorelease methods leaking
    text
    copied!<p><p> Hi everyone,</p> <p>I'm stuck these days on some memory leaks. The app I'm making is working like that :</p> <p>1 - Loads a file into memory<br> 2 - Create a screen according to some values read on that file<br> 3 - Display the view</p> <p>Far from now everything is normal when I start the app and get the first screen. There is no leaks.</p> <p>But when I want to load an other screen from the current view I got plenty of leaks from autoreleased objects. And I don't understand because when I load a new view from the current one the process is similar :</p> <p>1 - Desctruction of the current view<br> 2 - Loads a file into memory<br> 3 - Create a screen according to some values read on that file<br> 4 - Display the view</p> <p>Here are some concrete example of what is leaking :</p> <pre><code>-(NSString*)pathForApplicationName:(NSString*)appName withImage:(NSString*)imagePath { NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentPath = [searchPaths lastObject]; return [NSString stringWithFormat:@"%@/%@/assets/www/%@",documentPath,[self convertSpacesInDashes:appName],imagePath]; } </code></pre> <p>The stringWithFormat:.. is leaking. An other example :</p> <pre><code>-(UIColor*)convertHexColorToUIColor:(NSString*)hexColor { if ([hexColor length] == 7) { unsigned c = 0; NSScanner *scanner = [NSScanner scannerWithString:hexColor]; [scanner setScanLocation:1]; [scanner scanHexInt:&amp;c]; return [UIColor colorWithRed:((c&gt;&gt;16)&amp;0xFF)/255.0 green:((c&gt;&gt;8)&amp;0xFF)/255.0 blue:(©&amp;0xFF)/255.0 alpha:1.]; } else { return nil; } } </code></pre> <p>Same, colorWithRed:.. is leaking.</p> <p>I've read apple's documentation regarding autoreleased objects. And I've even tried to recreate a new pool like that, without any success : </p> <pre><code>-(UIView)myFonctionWhoGenerateScreens: for () { NSAutoreleasePool *subPool = [[NSAutoreleasePool alloc] init]; // There are all of the autoreleased method calls that are leaking... [subPool drain]; } } </code></pre> <p>I think I am missing something. Does anyone has an idea? </p> <p>Leak backtrace <img src="https://i.stack.imgur.com/GcHjc.png" alt="enter image description here"></p> <p>Thanks a lot.</p> <p>Edit : </p> <p>Here is how the return of the leaking function is handled in applyPropertyName:withPropertyType:onComponent:withValue:forStyling method :</p> <pre><code>else if ([propertyType isEqualToString:@"AB_IMAGE"]) { UIImage *image = [UIImage imageWithContentsOfFile:[self pathForApplicationName:applicationName withImage:value]]; @try { [component setValue:image forKey:propertyName]; } @catch (NSException *exception) { #if DEBUG_CONTROLLER NSLog(@" %@ Not key-value compliant for &lt;%@,%@&gt;",component,propertyName,image); #endif } } </code></pre> <p>Edit 2 : Here is the complete back trace <a href="http://ganzolo.free.fr/leak/%20Leak.zip" rel="nofollow noreferrer">http://ganzolo.free.fr/leak/%20Leak.zip</a></p> <p></p></p>
 

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