我是内存管理的新手,我搜索过类似的主题,但没有找到导致内存泄漏的简单示例。我正在使用Instruments测试我的应用程序,它说我在pushViewController中有144字节的内存泄漏。
RootViewController的:
- (IBAction)optionsAction
{
optionsViewController *ovc = [[optionsViewController alloc] init];
// MEMORY LEAK 100.0%
[self.navigationController pushViewController:ovc animated:YES];
[ovc release];
}
optionsViewController.h
@interface optionsViewController : UIViewController <ADBannerViewDelegate> {
UISlider *volumeSlider;
UISwitch *soundSwitch;
SystemSoundID SSID;
}
@property (nonatomic, retain) IBOutlet UISwitch *soundSwitch;
@property (nonatomic, retain) IBOutlet UISlider *volumeSlider;
@property (assign) SystemSoundID SSID;
@end
optionsViewController.m
- (void)dealloc
{
[volumeSlider release];
[soundSwitch release];
AudioServicesDisposeSystemSoundID(self.SSID);
[super dealloc];
}
您知道这次泄漏的原因是什么?你能说我应该在哪里搜索问题,rootViewController或optionsViewController?