0
c'est mon code, il ne libère la mémoire il atteint 60 mb et l'application tueProblème mémoire à l'aide NSData
for (int i = 0; i < [modelList compte]; i ++) {
[email protected]"http://192.168.0.101/images/projectimages/";
url=[url stringByAppendingString:[modelList objectAtIndex:i]];
url=[url stringByAppendingString:@".jpg"];
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
NSData *imageData=[[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:url]];
destinationPath=[documentsDirectory stringByAppendingString:@"/modelimages"];
destinationPath=[destinationPath stringByAppendingPathComponent:[modelList objectAtIndex:i]];
destinationPath=[destinationPath stringByAppendingString:@".jpg"];
[imageData writeToFile:destinationPath atomically:YES];
[imageData release];
//imageData=nil;
//[myurl release];
//[imageData release];
value=value+divideValue;
printf("%f\n",value);
[NSThread detachNewThreadSelector:@selector(updateProgressBar)toTarget:self withObject:nil];
}
Quelle est la valeur approximative de [nombre modelList]? Dans les centaines ou plus? – mahboudz
Url et destinationPath ne sont libérés automatiquement qu'une fois que cette routine a abandonné le contrôle à la boucle de démarrage. Cependant, à moins que la boucle for n'itéère plusieurs centaines de milliers de fois, ces chaînes n'atteindront pas 60 Mo. Est-ce que ce code obtient réellement des images et les écrit dans votre répertoire Documents? Comment pouvez-vous trouver des images là-bas? – mahboudz