I have a help web view which is displayed as a result of tapping the right nav button on a navigation control.
When the app starts the mem usage is at 10.55mb which increases to 14.00 when the help web view is displayed.
However when the help web view closes the mem usage only goes back to 13.88?
If I continue to open and close the help the mem usage slowly creeps up.
I therefore think I have not got the clean up working correctly for the help viewcontroller.
Here is the .h and .m files for the help
I used asssign rather than retain as I have seen that this helps to not hold on to items when not required to do so.
the method appDelegate.backToRoot simply pops the view off the stack.
My understanding tell me that I have this setup right but cannot understand the hold on memory plus slow creep usage
any tip please?
Thanks
When the app starts the mem usage is at 10.55mb which increases to 14.00 when the help web view is displayed.
However when the help web view closes the mem usage only goes back to 13.88?
If I continue to open and close the help the mem usage slowly creeps up.
I therefore think I have not got the clean up working correctly for the help viewcontroller.
Here is the .h and .m files for the help
Code:
#import <UIKit/UIKit.h>
@interface HelpViewController : UIViewController <UIWebViewDelegate>
{
NSString *htmlContent;
UIWebView *webView;
}
// setup properties
@property (assign, nonatomic) NSString *htmlContent;
@property (assign, nonatomic) UIWebView *webView;
@end
I used asssign rather than retain as I have seen that this helps to not hold on to items when not required to do so.
Code:
#import "HelpViewController.h"
#import "KPAppDelegate.h"
@implementation HelpViewController
@synthesize htmlContent;
@synthesize webView;
-(void) viewDidLoad
{
// always call the base method!
[super viewDidLoad];
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
// flush them first in case they are hanging around in memory
[webView release];
webView = nil;
webView = [[[UIWebView alloc] initWithFrame:webFrame] autorelease];
webView.backgroundColor = [UIColor grayColor];
[webView loadHTMLString: htmlContent baseURL: [NSURL URLWithString: @"http://www.google.ac.uk"]];
[self.view addSubview: webView];
// set nav bar title
self.title = @"Help";
// reference the app delegate to access isPPLVisible
KPAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
// add a right button to the navigation controller
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle: @"Done"
style: UIBarButtonItemStylePlain
target: appDelegate
action: @selector(backToRoot)] autorelease];
}
- (void) didReceiveMemoryWarning
{
/*
Asks the delegate for the view to scale when zooming is about to occur in the scroll view. This method is optional
*/
[super didReceiveMemoryWarning];
}
-(void) dealloc
{
// dump super
[super dealloc];
}
@end
the method appDelegate.backToRoot simply pops the view off the stack.
My understanding tell me that I have this setup right but cannot understand the hold on memory plus slow creep usage
any tip please?
Thanks