Sunday, December 15, 2013

Several primary questions about Objective-c memory, exceptions, and zombies

Memory problems:
When using xcode4.02 comes Instruments detection code testing tools found execute the same code to detect memory leaks sometimes, and sometimes they can not find, which is why? Instruments for detecting whether the project through the project on behalf of never appear in runtime memory overflow, or that Instruments can do static analysis of the code, pointing out the obvious problem of code written on?

The segment of random memory exception detection code snippet below:

 - (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {
static NSString * CellIdentifier = @ "Cell";

UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellIdentifier] autorelease];
}

NSString * cellText = [NSString stringWithFormat: @ "audio file% d", (indexPath.row +1)]; / / memory overflow
cell.textLabel.text = cellText;
if ([cellText isEqualToString: selectText]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
thisIndexPath = indexPath;
}
return cell;
}


Unusual problem:
How is a method declaration exception, so that the caller of the method must put their try-catch at compile time? (Similar to java or C # void funcName (Param1 param1) throws MyException)

Why we do not recommend ios platform applications use exceptions?

Another:
xcode4.02 zombies and how to open the log?

----------------------
Issue a little too much, but also help younger seniors please, thank you in advance.

Reply:
My own top.
Reply:
JAVA exception handling itself is bad.
So naturally there is no need to learn IOS bad things.
C / C + + exception handling can work well under IOS.
Open the zombies and log on.
You can modify and open the project in some settings in the Edit SCHEMA and Build.
Reply:
Open the Zombie:
Method one, adding environment variables, in the menu, select Product-> Edit Schema, select Run (App Name), in the Arguments following Environment Variables, add NSZombieEnabled, Value is YES.
Method Two, open Diagnostics, select Product in the same menu -> Edit Schema, select Run (App Name), under Diagnostics, open the Enable Zombie Objects Memory Management under
Reply:
Back to the third floor, I used the method of a non-significant effect. . . .
Method Two Memory Management under no Enable Zombie Objects check box.
Reply:
Code no memory leaks, sometimes tool displays wrong.
Reply:
But this instrument which really did not understand some places, some places displayed strange, but also experts can come to for advice Instrument

No comments:

Post a Comment