您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

使用Instruments解决EXC_BAD_ACCESS

2024/2/17 15:41:13发布24次查看
http://www.cocoachina.com/bbs/read.php?tid=55526 这里有一篇关于 使用 nszombieenabled和mallocstacklogging查找exc_bad_access问题所在的文章。 http://www.cocoachina.com/macdev/objc/2011/0219/2661.html 现在要介绍的其实是为上述方法添加了一个图形
http://www.cocoachina.com/bbs/read.php?tid=55526
这里有一篇关于使用nszombieenabled和mallocstacklogging查找exc_bad_access问题所在的文章。
http://www.cocoachina.com/macdev/objc/2011/0219/2661.html
现在要介绍的其实是为上述方法添加了一个图形界面。
错误代码:
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'heiti sc light'}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'heiti sc light'; min-height: 12.0px}span.apple-tab-span {white-space:pre}
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {
// override point for customization after application launch.
nsstring* s = [[nsstring alloc]initwithstring:@this is a test string];
s = [s substringfromindex:[s rangeofstring:@a].location];//内存泄露
[s release];
    [self.window makekeyandvisible];
return yes;
}
1.打开instruments工具,如果xcode是默认路径安装,那路径应该是/developer/applications/instruments.app
2.在弹出的对话框中选中,对应target的memory / zombies,选择ios simulator(真机好像没有这个选项)
3. 在左上角上选中choose target, 然后选择你生成的iphone app程序,一般会在工程文件夹的build/debug-iphonesimulator下
4.点击左上角的record按钮,让程序运行,当程序崩溃的时候会出现一个zombie messaged
5.通过分析下方表格的retain和release记录找到问题所在,通过点击stack trace可以看到源代码
ps:有时候我们可以使用build an anlayze功能查找错误。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product