以下の行でメモリリークが発生しました
NSURL *imageURL = [NSURL URLWithString:currentElementValue];
NSData *ndata = [NSData dataWithContentsOfURL:imageURL];
UIImage *image1 = [[UIImage alloc] initWithData:ndata];
私を助けてください。
以下の行でメモリリークが発生しました
NSURL *imageURL = [NSURL URLWithString:currentElementValue];
NSData *ndata = [NSData dataWithContentsOfURL:imageURL];
UIImage *image1 = [[UIImage alloc] initWithData:ndata];
私を助けてください。
線のように見えます
UIImage *image1 = [[UIImage alloc] initWithData:ndata];
正しくクリーンアップされていません。これを次のいずれかに変更します。
UIImage *image1 = [[[UIImage alloc] initWithData:ndata] autorelease];
また
UIImage *image1 = [UIImage imageWithData:ndata];
imageURL(NSURL
)とndata(NSData
)は自動リリースされるため、エラーがクリーンアップされます。
以下のように、関数の最後でローカルに作成されたオブジェクトを解放できます
NSURL *imageURL = [NSURL URLWithString:currentElementValue];
NSData *ndata = [NSData dataWithContentsOfURL:imageURL];
UIImage *image1 = [[UIImage alloc] initWithData:ndata];
[ndata release];
[imageURL release];
割り当てられるたびにオブジェクトがそのスコープ自体で解放されるように