I have an IntroViewController with a very large image, which increases the memory of my app by about 1.5MB. The image is set on a UIImageView within the View Controller's NIB.
Once the intro has finished, I call release
on the IntroViewController, which then successfully calls dealloc
on itself and calls release
on the large UIImageView. However, my memory in Instruments doesn't seem to come back down again. I can test the memory difference by simply renaming the image to the UIImageView in the NIB so it can't find anything, and then the memory drops by about 1.5MB.
So why am I not getting that memory back? Is there something that I'm missing which is stopping the UIImageView from being properly dealloc'd?
Thanks,
:-Joe
------- ADDED: 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
---- EDIT
Can anyone please help? I'm stumped, and it's causing my app to crash on the iPhone due to high memory :( can't figure out how to get rid of the stupid image! Grrrr...