私は今、iPhoneアプリでメモリリークの問題に悩まされています。データを間違って読み取らなければならないように感じます。メモリを割り当てるたびに、オーバーヘッドが多すぎてリークが発生し、データを解放してもメモリ使用量がほとんど低下しないか、まったく低下しないようです。2 日間無駄にしたのは、フリップサイド ビュー コントローラーの UIWebview が URL をロードし、アプリのメモリ使用量が 3 mb から 7 に跳ね上がったことです。dealloc メソッドで webview を解放しましたが、メモリの巨大なブロックはまだ生きています。誰にも何か提案はありますか。
- (void)viewDidLoad {
self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
nav_bar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width+20,45)];
[self.view addSubview:nav_bar];
[UINavigationBar release];
rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(done)];
item = [[UINavigationItem alloc] initWithTitle:@"Flipside View"];
item.rightBarButtonItem = rightButton;
item.hidesBackButton = YES;
[nav_bar pushNavigationItem:item animated:NO];
[rightButton release];
[item release];
NSAutoreleasePool *initPool = [[NSAutoreleasePool alloc] init];
web_view = [[UIWebView alloc]initWithFrame:CGRectMake(0,45,self.view.frame.size.width,self.view.frame.size.height - 45)];
web_view.autoresizesSubviews = YES;
web_view.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
NSString *urlAddress = @"http://www.tutorialpark.com/wpcontent/uploads/3/HeartBlending.jpg";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[web_view loadRequest:requestObj];
[self.view addSubview:web_view];
[web_view release];
[initPool release];
[super viewDidLoad];
}
- (void)dealloc {
[nav_bar removeFromSuperview];
[web_view removeFromSuperview];
[rightButton release];
[super dealloc];
}
インデントについては申し訳ありませんが、私は今非常に腹を立てており、対処したくありません。