1

同じビューに入るたびにメモリが増えています。リリースしても何も起こらず、古いアプリの問題で ARC を使用できません。この問題を解決する方法がわかりません。

#import <UIKit/UIKit.h>
#import "CareServices.h"

@interface AttachedImage : UIViewController<ServerConnectionDelegate,UIScrollViewDelegate>

{
  IBOutlet  UIImageView *imageView;
    CareServices *careServices;
    UIScrollView *_scrollView;
    UIView  *activityView;
    UIActivityIndicatorView *_activity;
}

@property (nonatomic,retain)UIImageView *imageView;
@end


#import "AttachedImage.h"
#import"XMLParserForOtherAttachments.h"
#import "ColorSchemes.h"

@implementation AttachedImage
@synthesize imageView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    activityView = [[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width/2.5,self.view.frame.size.height/2.5, 60, 60)];
    activityView.backgroundColor = [UIColor clearColor];

    [self.view addSubview:activityView];

    UIImageView *activityImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, activityView.frame.size.width, activityView.frame.size.height)];
    activityImageView.image = [UIImage imageNamed:@"indicatorImage.jpeg"];
    [activityView addSubview:activityImageView];
    [activityImageView release];


    _activity = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    [_activity setFrame:CGRectMake(activityView.frame.size.width/5.8, activityView.frame.size.height/5.3, 40, 40)];
    [activityView addSubview:_activity];
    [_activity startAnimating];
    [_activity release];


    careServices = [CareServices currentInstance];
    careServices.delegate = self;
    [[NSURLCache sharedURLCache] removeAllCachedResponses];

    [super viewDidLoad];

    self.navigationItem.title = @"Attachment View";
//    self.view.backgroundColor = [ColorSchemes sharedInstance].primaryColor1;

    self.view.backgroundColor = [UIColor blackColor];;
    // Do any additional setup after loading the view from its nib.
}

-(void)viewDidAppear:(BOOL)animated {

 NSString *senderTagStr;
    NSUserDefaults *senderD = [NSUserDefaults standardUserDefaults];
    senderTagStr = [senderD valueForKey:@"sender tag"];
    _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    _scrollView.maximumZoomScale = 4.0;
    _scrollView.minimumZoomScale = 1.0;
    _scrollView.delegate = self;
    _scrollView.contentSize = CGSizeMake(400, 500);
    if (careServices.loginMode == ELoginModeDemo) {
    if ([senderTagStr isEqualToString:@"0"]) {
        imageView.image = [UIImage imageNamed:@"R1.bmp"];
    }
    else {
        imageView.image = [UIImage imageNamed:@"8.jpg"];
      }
    }

 else {

  NSString *str = [NSString stringWithString:[XMLParserForOtherAttachments sharedManager].fileURlStr];
    NSString *trimmedStr = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    NSData *imgData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:trimmedStr]];
        UIImage   *myImage = [UIImage imageWithData:imgData];
    imageView.image = myImage;
        [imgData release];
    }
    [_scrollView addSubview:imageView];
    [self.view addSubview:_scrollView];
    [_activity stopAnimating];
    [activityView removeFromSuperview];    

}
- (void)viewDidUnload {

    [[NSURLCache sharedURLCache] removeAllCachedResponses];

    self.imageView = nil;
    [super viewDidUnload];

}

- (void)dealloc{
    [imageView release];
    [super dealloc];
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return imageView;
}
@end
4

1 に答える 1

1

Heapshot Analysis の使用法を習得すれば、問題のある割り当て/実装を見つけるのは非常に簡単です。

ヒープショット分析を使用すると、実行中にスナップショットを作成して、一定期間の成長を検出できます。もちろん、多くの場合、これをユーザー アクションに関連付けることができます。たとえば、View Controller を iOS のナビゲーション スタックにプッシュしてから、一歩下がって、そうすることで何が成長したかを簡単に判断できます。次に、成長の原因となった実装に移動します。

于 2012-11-06T08:38:13.320 に答える