これが私のコードです:ヘッダー:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
UIImageView *imageView;
NSMutableArray *arrayWithImages;
}
- (IBAction)startAnimation:(id)sender;
- (IBAction)cleanMemory:(id)sender;
@end
実装:
#import "ViewController.h"
@implementation ViewController
......
- (IBAction)startAnimation:(id)sender {
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
arrayWithImages = [[NSMutableArray alloc] initWithObjects:
[UIImage imageNamed:@"pic1"],
[UIImage imageNamed:@"pic2"],
[UIImage imageNamed:@"pic3"],
[UIImage imageNamed:@"pic4"],
[UIImage imageNamed:@"pic5"],
[UIImage imageNamed:@"pic6"],
[UIImage imageNamed:@"pic7"],
[UIImage imageNamed:@"pic8"],nil];
imageView.animationImages = arrayWithImages;
imageView.animationDuration = 3;
imageView.animationRepeatCount = 1;
[self.view addSubview:imageView];
[imageView startAnimating];
}
- (IBAction)cleanMemory:(id)sender {
[arrayWithImages removeAllObjects];
[arrayWithImages release];
arrayWithImages= nil;
[imageView removeFromSuperview];
[imageView release];
imageView = nil;
}
@end
私は持っていViewController
てview
、2つのボタンがあります。startAnimation
アクションのある最初のボタン。これにより、が作成されUIImageView
、NSMutableArray
アニメーションが開始されます。アクション付きの2番目のボタン。cleanMemory
これは、で作成したものをすべてクリーンアップしstartAnimation
ます。楽器から始めるProfile
と、プログラムに、ボタンを押すとアニメーションに変わり、アニメーションの後に ボタンを押しますが、同じです...なぜですか?開始値(4 mb Real Mem)までメモリをクリーンアップしません。どこに問題があるのか説明してもらえますか?Activity Monitor
4 mb Real Mem
startAnimation
16 mb Real Mem
cleanMemory
16 mb Real Mem