1

ゾンビが原因で iPhone アプリがクラッシュするか、メモリ リークが発生しています。コードを 3 行に絞り込み、コードをコメント化/コメント解除することで、2 つのうちの 1 つを確実に発生させることができます。バグは、結果のリスト (tableView) とマップといくつかのラベルを含む詳細ページの間のナビゲーションで発生し、マップから結果のリストに戻る最初のナビゲーションでメモリ リークが発生し、おそらく 5/ 6 回別の結果に移動して戻る。

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

#define METERS_PER_MILE 1609.344

@interface ResDetailsPageVC : UIViewController <MKMapViewDelegate, UIAlertViewDelegate>  {

UISegmentedControl *mapTypeSwitcher;
MKMapView *mapView;      

UILabel *nameLabel;
UIButton *addressLabel;
UILabel *telephoneLabel;

NSString *address;

}

@property (nonatomic, retain) IBOutlet UISegmentedControl *mapTypeSwitcher;
@property (nonatomic, retain) IBOutlet MKMapView *mapView;

@property (nonatomic, retain) IBOutlet UILabel *nameLabel;
@property (nonatomic, retain) IBOutlet UIButton *addressLabel;
@property (nonatomic, retain) IBOutlet UILabel *telephoneLabel;


- (IBAction)segmentedControlIndexChanged;
- (IBAction)callButtonClick;
- (IBAction)addressClick;

- (void) callNumber;

@end






@synthesize mapView;
@synthesize mapTypeSwitcher;

@synthesize nameLabel, addressLabel, telephoneLabel;

- (void)dealloc {

// if these lines are commented out - memory leak
// if not - zombie?!
/*self.telephoneLabel = nil;
self.addressLabel = nil;
self.nameLabel = nil;*/
self.mapView = nil;
self.mapTypeSwitcher = nil;

[super dealloc];

}
4

2 に答える 2

0

これをお勧めします:

- (void)dealloc {
[telephoneLabel release]; telephoneLabel = nil;
[addressLabel release]; addressLabel = nil;
....

[super dealloc];
}
于 2012-01-31T17:06:12.370 に答える
0

他のコードのどこかで、これら 3 つのプロパティのいずれかにアドレスが格納されている同じオブジェクトが使用されていますが、その別のコードはオブジェクトを適切に保持していません。

于 2012-01-31T17:05:45.480 に答える