Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional iPhone and iPad Application Development
This is the forum to discuss the Wrox book Professional iPhone and iPad Application Development by Gene Backlin; ISBN: 978-0-470-87819-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional iPhone and iPad Application Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 5th, 2011, 10:44 AM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default Chapter 13

I am getting an unexpected result running the PerformanceTest program. The obvious DataItem leak is not being noted in instruments. The NSString that is not released is detected.

Also, Listing 13-4 does not have a memory leak since the [item release]; line is included as is the [str release]; in the method. These lines are missing in Listing 13-6, as they should be, to demonstrate the leak.

Bob
  #2 (permalink)  
Old April 5th, 2011, 11:41 AM
Wrox Author
Points: 362, Level: 6
Points: 362, Level: 6 Points: 362, Level: 6 Points: 362, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Posts: 61
Thanks: 0
Thanked 9 Times in 7 Posts
Default

Quote:
Originally Posted by thepianoguy View Post
I am getting an unexpected result running the PerformanceTest program. The obvious DataItem leak is not being noted in instruments. The NSString that is not released is detected.

Bob
Is this using Xcode 4 Bob ?

If so, I have notice this happening a number of times with current code I am writing for clients with Xcode 4.
  #3 (permalink)  
Old April 5th, 2011, 12:02 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

I built the project in Xcode 4 but have run it in Instruments 2.7 from Xcode 3 and Instruments 4.0 in Xcode 4 with the same results. Not that I expect a different result, but I will be redoing the entire project again in Xcode 3 to see if anything turns out differently.

Bob
  #4 (permalink)  
Old April 6th, 2011, 09:42 AM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

Having redone the project in Xcode 3.2.6 with the same results (i.e. the leak of DataItem not detected), I did a little research. Several sources (stackoverflow has several responses to related issues) claim that Leaks only detects a leak if a reference to the object no longer exists. To test this I did the following

Code:
-(IBAction)addDataToDictionary:(id)sender
{
	NSString *str = nil;
	DataItem *item = [[DataItem alloc] init];
	item.age = self.ageTextField.text;
	item.name = self.nameTextField.text;
	
	[self.dataArray addObject:item];
		  	
	str = [[NSString alloc] initWithFormat:@"Current count = %d",[self.dataArray count]];
	
	totalCountLabel.text = str;
	if ([self.dataArray count]%10 == 0) {
		[self printLog];
	}
}

-(void)printLog
{
	NSLog(@"The count has gone up by 10");
	NSLog(@"removing all objects");
	[self.dataArray removeAllObjects];
}
After the objects are removed from the array, the leaks do show up. No references, but a retain count greater than 0. This matches the behavior that the stackoverflow respondent said would occur
http://stackoverflow.com/questions/1...ure-they-exist


Bob
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 Try It! MikersSU BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 11 April 1st, 2012 05:14 AM
Chapter 13 rock1233 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 October 6th, 2009 12:18 PM
Chapter 13 bwoll BOOK: Beginning Access 2003 VBA 1 June 7th, 2007 03:57 PM
Chapter 13 ElMorenito BOOK: Beginning ASP 3.0 0 January 14th, 2005 01:56 PM



All times are GMT -4. The time now is 10:25 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.