• Find Zombies


    发现僵尸Find Zombies

     

    僵尸仿形模板使用拨款的仪器来测量你的应用一般的内存使用情况,对检测overreleased“僵尸”的对象,是一个焦点,是在他们已经被释放,不再存在所谓的对象。The Zombies profiling template uses the Allocations instrument to measure general memory usage in your app, with a focus on the detection of overreleased “zombie” objects—that is, objects that are called after they’ve been released and no longer exist.

    在这个模板,配置工具配置为使nszombie检测。这是一个调试模式,设置环境变量nszombieenabled真实,指导编译器替代任何对象被释放到零再也没有那些对象的引用计数型NSZombie对象应该存在。如果一个消息然后发送到一个释放的对象(这是现在nszombie对象),僵尸的标记,应用程序崩溃,记录停止,和僵尸消息对话框。然后,您可以检查僵尸对象的保留和释放历史,以确定问题发生的确切位置。In this template, the Allocations instrument is configured to enable NSZombie detection. This is a debug mode that sets the environment variable NSZombieEnabled to true, directing the compiler to substitute an object of type NSZombie for any objects that are released to a reference count of zero—no more of those objects should exist. If a message is then sent to one of these deallocated objects (which are now NSZombie objects), the zombie is flagged, the app crashes, recording stops, and a Zombie Messaged dialog appears. You can then examine the retain and release history of the zombie object to determine exactly where the problem occurred.

    IMPORTANT

    僵尸模板造成持久性存储器增长因为它改变你的环境,对象不会被释放释放技术。这是预期的行为,但它意味着除了僵尸标志和内存地址历史之外,分配工具提供的任何其他统计数据都应该被忽略。你也不应该在僵尸模板中添加泄漏工具,因为它会产生不准确的结果。对于iOS应用程序,使用僵尸模板与iOS模拟器,而不是物理设备。The Zombies template causes persistent memory growth because it changes your environment so that deallocated objects are never technically deallocated. This is expected behavior, but it means that aside from zombie flags and memory address histories, any other statistics provided by the Allocations instrument should be ignored. You also shouldn’t add the Leaks instrument to the Zombies template, as it will produce inaccurate results. For iOS apps, use the Zombies template with the iOS Simulator, rather than a physical device.

    在你的应用程序中寻找僵尸To look for zombies in your app
    1. 运载工具。Launch Instruments.

    2. 在出现的分析模板选择对话框中,单击“僵尸”。In the profiling template selection dialog that appears, click Zombies.

    3. 从目标设备和流程列表中选择您的设备和应用程序。Choose your device and app from the target device and process lists.

    4. 单击“选择”创建跟踪文档。Click Choose to create a trace document.

    5. 单击“记录”按钮在工具栏(或按command-r)开始记录。Click the Record button (image: ../Art/inline_record_button_2x.png) in the toolbar (or press Command-R) to begin recording.

    6. 正常使用你的应用程序。Use your app normally.

      如果调用了一个函数对象,国旗插在时间轴面板和僵尸的消息对话框,提示信息是在一个特定的内存地址发送一个释放对象。If a call is made to a deallocated object, a flag is inserted in the timeline pane and a Zombie Messaged dialog appears, indicating that a message was sent to a deallocated object at a specific memory address.

      如果你关闭僵尸消息对话框,你可以打开它点击旗帜。If you close the Zombie Messaged dialog, you can reopen it by clicking the flag.

    7. 点击箭头旁边的僵尸的内存地址显示在详细信息窗格中的僵尸对象的历史记忆,以及相应的引用计数和方法调用。Click the focus arrow (image: ../Art/icon_detail_pane_gotoarrow_2x.png) next to the zombie’s memory address to display the memory history of the zombie object in the detail pane, along with corresponding reference counts and method calls.

    8. 在详细窗格中选择僵尸事件(或任何其他要调查的事件)。Select the Zombie event (or any other event you want to investigate) in the detail pane.

    9. 记者command-3显示在检查员的扩展的详细地区选定的事件堆栈跟踪。Press Command-3 to display a stack trace for the selected event in the extended detail area of the inspector.

    10. 单击折叠按钮在扩展的详细地区隐藏在堆栈跟踪的系统调用。这样可以更容易地找到应用程序的方法。Click the Collapse button (image: ../Art/inline_hidesystemcalls_button_2x.png) in the extended detail area to hide system calls in the stack trace. This makes it easier to locate your app’s methods.

      在你的应用程序进行调用的都是黑色的,之前有一个用户代码图标。Calls made by your app are colored black and preceded by a user code icon (image: ../Art/inline_usercode_icon_2x.png).

    11. 双击堆栈跟踪中的一个方法,以在工具中显示其代码。Double-click a method in the stack trace to display its code in Instruments.

    12. 点击Xcode按钮在细节窗格顶部在Xcode打开代码编辑。Click the Xcode button (image: ../Art/inline_xcode_2x.png) at the top of the detail pane to open the code in Xcode for editing.

    虽然工具可以帮助你检测僵尸,但仍然需要仔细查看相关的内存历史和代码,以便识别和解决问题。以下场景是僵尸的常见原因:Although Instruments can help you detect zombies, you still need to look carefully through the related memory history and your code in order to identify and resolve the problem. The following scenarios are common causes of zombies:

    • 对象已被释放(或自动释放),和您的应用程序试图将它再次发布。An object has already been released (or autoreleased), and your app tries to release it again.

    • 一个对象在它应该被保留时没有被保留。An object hasn’t been retained when it should have been.

    • 另一个调用是在释放对象后对其发出的。Some other call is made to an object after it has been released.

  • 相关阅读:
    【设计模式】适配器模式
    【设计模式】原型模式
    【设计模式】建造者模式
    【设计模式】抽象工厂模式
    我的稳定的SpingBoot项目依赖
    Vue中使用iconfont
    Vue-兄弟组件传值
    CSS让高度百分百的方案
    css修改overflow滚动条默认样式
    CSS去除input和textarea点击选中框
  • 原文地址:https://www.cnblogs.com/zyingn/p/Find_Zombies.html
Copyright © 2020-2023  润新知