在设备上调试找不到过度释放的对象
我有一个相当大的应用程序,它可以在模拟器中运行,但在 iPhone 设备上的过度发布的对象场景中创建。 NSzombies 似乎是一条可行的路线,只不过该对象没有在模拟器上过度释放,并且 NSZombies 无法在设备上运行。经过几个小时的记录,我似乎能够将其固定在运行 -
开始
[locManager startUpdatingLocation] 和 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation) 之间的某个地方*)oldLocation
这解释了为什么它可以在模拟器上工作,我检测到没有定位能力并且不运行该定位代码。
当我在 [locManager startUpdatingLocation] 之前和之后内联 NSLog 时,我的 NSString 对象已分配并存在。但是当应用程序执行并命中 locationManager: NSLog 时,会显示 NSString 已被释放,消失了。这个字符串对象与位置处理或功能完全无关。不相关的 NSString。我已经注释掉了所有其他潜在的活动,并注释掉了所有显式的发布代码,但找不到它发生的时刻。
我更沮丧的是 lldb 似乎不支持观察点而 gdb 支持它们,但这个版本似乎它们不起作用! gdb 将设置一个硬件观察点,然后 Xcode 表示其正在运行,但 30 分钟后仍然没有视觉活动或中断。
我使用的是 Lion、Xcode 4.1.1,还有太多咖啡。
我应该采取什么方法才能在如此狭窄的活动范围和有限的工具中找到这个已发布的 NSString 对象?
I have a rather large app which works in the simulator but creates in an over-released object scenario on the iPhone device. NSzombies would seem to be the route to go except that the object is not over-released on the simulator and NSZombies does not function on the device. Through hours of logging I seem to be able to pin it down to someplace between when I run -
[locManager startUpdatingLocation] and the start of -
(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
That explains why it works on the simulator, I detect no location ability and do not run that location code.
When I NSLog in-line just before and after [locManager startUpdatingLocation] my NSString object is allocated and present. But when the app executes and it hits locationManager: NSLog shows the NSString is deallocated, gone. THis string object has absolutely nothing to do with location handling or functionality. Unrelated NSString. I have commented out all other potential activity, and commented out all explicit release code and can't find the moment it happens.
I'm further frustrated that lldb seems not to support watchpoints and gdb supports them but this version seems that they don't work ! gdb will set a hardware watchpoint and then Xcode says its running but 30 minutes later there is still no visual activity or break.
I'm on Lion, Xcode 4.1.1, and too much coffee.
What approach should I take to find this released NSString object in such a narrow spectrum of activity and limited tools ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
曾几何时,我有一个复杂的情况来定位已释放的对象,因此我只是从该对象继承到 MyObject 并按以下方式重写保留和释放:
这是 DebugString.h 文件:
这是 DebugString.m文件:
我在这个方法中放置了一个断点,并在我预计崩溃的阶段将它们打开。后来我开始一一查看这个调用,发现了一个问题。它很复杂,但有时可能会有所帮助,而且我从未在论坛中看到过这种方法。也许它也会对你有帮助。
Once upon a time I had a complex case for locating over released object, so I just inherited from this object to MyObject and overriden a retain and release in a following way:
Here is the DebugString.h file:
And here is the DebugString.m file:
I put a break points inside of this methods and turned them on at the phase when I expected a crash. Afterward I just started to go through this calls one by one and found an issue. It is complex, but it may help sometime and I never saw such approach described in forums. Maybe it will help you also.
在模拟器中运行时手动调用位置“didUpdate” - 启动位置管理器后,至少两次调用,超时约五秒。这应该会触发与手机上相同的错误,然后你可以使用 NSZombies。
另外,模拟器应该能够运行位置代码,我认为这在 4.2 中被破坏,但在 4.1 中没问题。
Call the location "didUpdate" manually when running in the simulator - at least two calls, timed out about five seconds, after you start up the location manager. That should trigger the same bug as on the phone, then you can use NSZombies.
Also, the simulator SHOULD be able to run location code, I thought that was broken in 4.2 but OK in 4.1.