Note that there are some explanatory texts on larger screens.

plurals
  1. POmemory leak in webview after one minute only by instrument
    text
    copied!<p>this is my first iOS App, i follow apple documentation and stackoverflow answers, in xcode my app is working as charm on both simulator and device, but on instrument i have a memory leak after 50 - 70 seconds from app launch.</p> <p>i use tab controller with 3 view controllers,3 webviews, each webview is showing a web page like this:</p> <pre><code>&lt;html dir="rtl"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Language" content="en-us"&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;link rel="stylesheet" href="newstyle.css" type="text/css" /&gt; &lt;script type="text/javascript" src="js/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/iphone.js"&gt;&lt;/script&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body style="color:#FFFFFF"&gt; &lt;div align="center"&gt; &lt;table border="0" width="320" id="table1" cellspacing="5"&gt; &lt;tr&gt; &lt;form method="get"&gt; &lt;input type="hidden" name="index" value="&lt;?=$_GET['index']?&gt;"&gt; &lt;input type="hidden" name="cat" value="&lt;?=$_GET['cat']?&gt;"&gt; &lt;input type="hidden" name="area" value="&lt;?=$_GET['area']?&gt;"&gt; &lt;td class="search"&gt; &lt;div class="back"&gt;&lt;a href="javascript:window.history.back()"&gt;back&lt;/a&gt;&lt;/div&gt; &lt;div class="srchbox"&gt;&lt;a href="#reviews"&gt;&amp;nbsp;&lt;sub&gt;notes (&lt;?=countDataPages('iresturant_reviews','status=1 and clientIIndex ='.$_GET['index'].' and clientID='.$_GET['id'], 1);?&gt;)&lt;/sub&gt;&lt;/a&gt;&lt;div id="rates"&gt;&lt;div id="actualrates" style="width:&lt;?=round($mydatad[7] * 10)?&gt;%"&gt;&lt;/div&gt;&lt;/div&gt; &lt;/td&gt; &lt;/form&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="padding-left: 10px; padding-right: 10px" width="265"&gt; &lt;div class="justBox" style="padding:10px;"&gt; &lt;b&gt;&lt;?=unFormatData($mydata[1])?&gt;&lt;/b&gt;&lt;br&gt; &lt;span style="font-weight: 400"&gt;&lt;?=$catTitle[$mydata[3-$minusIndex]]?&gt; &lt;br&gt;&lt;br&gt; &lt;?=$areaTitle[$mydata[4-$minusIndex]]?&gt;&lt;br&gt; &lt;?=unFormatData($mydatad[3])?&gt; &lt;/span&gt; &lt;p align="left" style="margin:0px;margin-top:15px;"&gt; &lt;a href="page1.php?id=&lt;?=$mydata[0]?&gt;&amp;index=&lt;?=$_GET['index']?&gt;"&gt;&lt;img border="0" src="images/zx.png" width="40" height="40"&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp; &lt;a href="page2.php?id=&lt;?=$mydata[0]?&gt;&amp;index=&lt;?=$_GET['index']?&gt;"&gt;&lt;img border="0" src="images/xz.png" width="40" height="40"&gt;&lt;/a&gt; &lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="padding-left: 10px; padding-right: 10px"&gt; &lt;? $imgFile = 'uimages/index_'.$_GET['index'].'_'.$mydata[0].'.jpg'; if (file_exists($imgFile)) { ?&gt; &lt;img src="&lt;?=$imgFile?&gt;" width="100%" align="right" style="margin-left:30px;"&gt;&lt;p&gt; &lt;? } ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="padding-left: 10px; padding-right: 10px"&gt;&lt;br&gt;&lt;br&gt; &lt;img border="0" src="images/phone.png" width="30" height="30" align="absmiddle"&gt; &amp;nbsp; &lt;?=unFormatData($mydata[5-$minusIndex])?&gt;&lt;br&gt; &lt;img border="0" src="images/web.png" width="30" height="30" align="absmiddle"&gt; &amp;nbsp; &lt;?=unFormatData($mydatad[4])?&gt;&lt;/span&gt; &lt;br&gt;&lt;br&gt;&lt;?=unFormatData($mydatad[2])?&gt; &lt;p style="padding-right:10px;line-height:200%" &gt; &lt;/p&gt;&lt;br&gt;&amp;nbsp; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="search"&gt; &lt;div class="back"&gt;&lt;a href="javascript:window.history.back()"&gt;back&lt;/a&gt;&lt;/div&gt; &lt;p style="margin-right: 10px; margin-top: 5px"&gt; &lt;a name="reviews"&gt;&lt;/a&gt;&lt;font color="#FFFFFF"&gt;reviews&lt;/font&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="padding-left: 10px; padding-right: 10px" &gt; &lt;? $data = getAllData('iphone_reviews','status=1 and clientIIndex ='.$_GET['index'].' and clientID='.$_GET['id'].' order by date desc'); for ($i=0; $i &lt; sizeof($data); $i++) { ?&gt; &lt;div class="justBox" style="padding:10px;"&gt; &lt;p style="margin:5px;"&gt;&lt;?=unFormatData($data[$i][3])?&gt;&lt;/p&gt; &lt;p dir="ltr" style="margin:0px;"&gt;&lt;?=date("F j, Y h:i A", $data[$i][7])?&gt;&lt;/p&gt; &lt;p style="margin:0px;font-weight: 400; padding:10px;"&gt;&lt;?=unFormatData($data[$i][5])?&gt;&lt;/p&gt; &lt;/div&gt; &lt;hr size="1"&gt; &lt;? } ?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="search"&gt; &lt;div class="back"&gt;&lt;a href="javascript:window.history.back()"&gt;back&lt;/a&gt;&lt;/div&gt; &lt;p style="margin-right: 10px; margin-top: 5px"&gt; &lt;font color="#FFFFFF"&gt;review&lt;/font&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td style="padding-left: 10px; padding-right: 10px"&gt; &lt;div id="addFrm"&gt; &lt;br&gt; name&lt;br&gt; &lt;input type="text" id="name" size="20" style="width:100%"&gt;&lt;br&gt; &lt;br&gt; review&lt;br&gt; &lt;textarea rows="2" id="comment" cols="20" style="width:100%; height:71"&gt;&lt;/textarea&gt;&lt;br&gt; &lt;br&gt; rate &lt;?=$oTitle?&gt;&lt;select size="1" id="rate"&gt; &lt;? for ($i=10; $i &gt; 0; $i--) { echo '&lt;option value="'.$i.'"&gt;'.$i.'&lt;/option&gt;'; } ?&gt; &lt;/select&gt;&lt;/span&gt; &lt;span lang="ar-sy"&gt;from 10&lt;br&gt; &lt;br&gt; &lt;button type="button" class="submitbutton" onclick="submitComment()"&gt;send&lt;/button&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; </code></pre> <p> </p> <p>using xcode > app is running perfect on simulater and device with no errors at all.</p> <p>using instrument > if i didn't do any action inside webview, no memory leak at all, when i begin clicking and moving inside the web page, after around a minute i receive a memory leak.</p> <p>in the beginning, i thought its because i run 3 webviews on same time, but when i make a test on 1 webview, same problem occurred.</p> <p>this is my code:</p> <pre><code>#import "SecondSection.h" #import "NamesViewController.h" #import "TypesViewController.h" #import "AreasViewController.h" @implementation SecondSection - (void)loadView { UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bk.png"]]; self.view = contentView; [contentView release]; // Declare all three view controllers NamesViewController *NamesInfoController = [[[NamesViewController alloc] initWithNibName:@"DetailViewController" bundle:[NSBundle mainBundle]] autorelease]; TypesViewController *typesViewController = [[[TypesViewController alloc] init] autorelease]; AreasViewController *areasViewController = [[[AreasViewController alloc] init] autorelease]; // Set a title for each view controller. These will also be names of each tab NamesInfoController.title = @"names"; typesViewController.title = @"types"; areasViewController.title = @"areas"; NamesInfoController.tabBarItem.image = [UIImage imageNamed:@"names.png"]; typesViewController.tabBarItem.image = [UIImage imageNamed:@"types.png"]; areasViewController.tabBarItem.image = [UIImage imageNamed:@"areas.png"]; // Create an empty tab controller and set it to fill the screen minus the top title bar UITabBarController *tabBarController = [[UITabBarController alloc] init]; tabBarController.view.frame = CGRectMake(0, 0, 320, 460); // Set each tab to show an appropriate view controller [tabBarController setViewControllers: [NSArray arrayWithObjects:NamesInfoController, typesViewController, areasViewController, nil]]; // Clean up objects we don't need anymore [NamesInfoController release]; [typesViewController release]; [areasViewController release]; // Finally, add the tab controller view to the parent view [self.view addSubview:tabBarController.view]; } - (void)dealloc { [super dealloc]; } - (void)viewWillDisappear { } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; } #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; } - (void)viewDidUnload { [super viewDidUnload]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } @end </code></pre> <p>where is the problem ? my second question and maybe it will help to resolve first problem, how to make the tabbar buttons, load the webview from url request on second time click, to explain more: when i first click a tabbar button1, it loads a view controller1 which loads a webview1 which loads a url request, click another tabbar button2 then go back to tabbar button1, it doesn't load the webview1 again, it only show it as you left it,because tabbar related to viewcontroller not to webview. how to fix it.</p> <p>thanx in advance for any help</p> <p>UPDATE: @Alexander here is sample code from main window before second section:</p> <pre><code>- (IBAction)rests:(id)sender; { HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; [self.navigationController.view addSubview:HUD]; HUD.delegate = self; HUD.labelText = @"Loading"; [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES]; SecondSection *zcontroller = [[SecondSection alloc] init]; zcontroller.title = @"macaesar"; [[self navigationController] pushViewController:zcontroller animated:YES]; [zcontroller release]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload