iDevGames Forums
release memory calling HTMLs files - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: release memory calling HTMLs files (/thread-2011.html)



release memory calling HTMLs files - imaumac - Dec 21, 2008 09:41 PM

Hi every one !....
I have a UIView with 4 buttons, and every button call a file.HTML (4 html in total)
but in instrument, on activity monitor every time I press a button calling a HTML, the memory increases, and add 4 or 5 MB each time pressing.

when the app reach 37 MB (on activity monitor) then the app crash.

I just can press only 7 times any button, then the app crash.
my app is not cleaning (release) each HTML, how can I fix please.
how can I release memory ?

i have this code on each button....

Quote:- (IBAction)IBAc_ojo1: (id)sender {
if (webView != nil)
[webView release];
webView = [[UIWebView alloc] initWithFrame:[myHTML_ojo1 bounds]];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"head-mandiblev" ofType:@"html"];
NSString *html = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[webView loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath] isDirectory:YES]];
[webView setScalesPageToFit:YES];
[myHTML_ojo1 addSubview:webView];


I realy, realy need any kind of help.
thanks a lot !


release memory calling HTMLs files - maximile - Dec 22, 2008 03:58 AM

I'm not at my computer, but I assume addSubview retains the view. Do you remove the webView from its superview before adding the new one?


release memory calling HTMLs files - imaumac - Dec 22, 2008 06:37 AM

how should I remove a webView before call a new one please ?
thanks for your help !

and here is my small project to download
you can see the code.

http://www.1572-8.com/zzz-xcode-testing/skeleton-html.zip


release memory calling HTMLs files - imaumac - Dec 23, 2008 07:49 AM

maximile Wrote:I'm not at my computer, but I assume addSubview retains the view. Do you remove the webView from its superview before adding the new one?

i dont know how to do it, please could you show me how to do it ?
thansk a lot !