我有一个非常大的图像IntroViewController,这增加了我的应用程序的内存大约1.5MB。该图像设置在视图控制器的NIB中的UIImageView上。我的应用程序如何在内存中显示图像?
一旦介绍完成后,我会在IntroViewController上调用release
,然后它自己成功调用dealloc
并在大型UIImageView上调用release
。然而,我在乐器中的记忆似乎没有再次回落。我可以通过将图像重命名为NIB中的UIImageView来测试内存差异,以便找不到任何内容,然后内存下降大约1.5MB。
那么,为什么我不能回忆那些回忆呢?是否有什么,我想念正在停止UIImageView正确dealloc'd?
感谢,
:-Joe
-------增加:CODE ------
#import <UIKit/UIKit.h>
@class AppDelegate_iPhone;
@interface IntroViewController : UIViewController
{
AppDelegate_iPhone *appDelegate;
UIImageView *wheelImageView;
UIView *copyOverlayView;
}
@property (nonatomic, retain) IBOutlet UIImageView *wheelImageView;
@property (nonatomic, retain) IBOutlet UIView *copyOverlayView;
- (void)startAnimation;
@end
@implementation IntroViewController
@synthesize wheelImageView, copyOverlayView;
- (void)viewDidLoad
{
[super viewDidLoad];
appDelegate = (AppDelegate_iPhone *)[[UIApplication sharedApplication] delegate];
[self startAnimation];
}
- (void)viewDidDisappear:(BOOL)animated
{
[self.wheelImageView removeFromSuperview];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload
{
[super viewDidUnload];
self.wheelImageView.image = nil;
appDelegate = nil;
}
- (void)dealloc
{
[wheelImageView release];
[copyOverlayView release];
[super dealloc];
}
- (void)startAnimation
{
self.wheelImageView.transform = CGAffineTransformMakeScale(0.5, 0.5);
[UIView beginAnimations:@"wheelScale" context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(wheelScaleDidFinish)];
self.wheelImageView.transform = CGAffineTransformMakeScale(1.0, 1.0);
[UIView commitAnimations];
[UIView beginAnimations:@"copyOverlayFade" context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelay:1.0];
self.copyOverlayView.alpha = 0;
[UIView commitAnimations];
}
- (void)wheelScaleDidFinish
{
[appDelegate introAnimationFinished];
}
@end
----编辑
灿任何人都请帮忙?我很难过,这导致我的应用程序崩溃在iPhone上由于高内存:(无法弄清楚如何摆脱愚蠢的形象!Grrrr ...
原因是UIImage imageNamed:和朋友维护一个图片缓存。在压力下,系统将释放内存。 – 2010-08-28 07:05:50
所以虽然有autorelease,但有些对象有自己的缓存?这是一个鲜为人知的事实,谢谢。但是,你说在压力下系统会释放内存,但在实践中,对于我来说,手机会因内存不足而崩溃,并且泄漏仍会显示缓存的图像! – jowie 2010-08-28 12:17:55