Reputation: 1075
I've an iOS app with 3 views in a TabBarViewController:
The first is for parsing JSON data from a website, and display 1-3 pictures with a textarea. The second is a contact view; google maps SDK with another text area. The third view is a webView, used to stream video from a webcam (imported by HTML file).
The first view takes me 35.5MB to display (with one picture). After I switch on the second view with TabBarViewController, I am using 75MB of memory (if I come back on the first view, it's about 72Mb). Finally, if I go to the third view (the webView), memory allocation is at about 90MB, unless I'm watching the streaming video from the webcam, when the the memory rises to around 170MB.
I don't know if this is acceptable or not.
I'm using ARC, but I don't use dealloc in my classes. Can I use dealloc when I am using a TabBarViewController? I would like, for example, to dealloc all of the views when I'm changing views with the TabBarViewController, since my memory allocation never decreases.
webView code:
-(void) viewDidLoad{
[super viewDidLoad];
self.fileUrl = [[NSBundle bundleForClass:[self class]]URLForResource:@"myHTML" withExtension:@"html"];
self.requestURL = [NSURLRequest requestWithURL:self.fileUrl];
[_webView loadRequest:self.requestURL];
}
-(void) viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:NO];
_webView = nil;
self.fileUrl = nil;
self.requestURL = nil;
[_webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML = \"\";"];
}
Upvotes: 0
Views: 432
Reputation: 1075
Use WKWebView instead of Webview is really good for memory !
Other tips ? Google Maps SDK takes too much memory !
Upvotes: 1
Reputation: 594
I'd suggest clearing out the webcam web view after you shift from it using the -viewWillDisappear method.
Upvotes: 0