简体   繁体   English

iPhone/Objective-C - QuartzCore 库中的 Memory 泄漏

[英]iPhone/Objective-C - Memory leaks in QuartzCore library

I am running the Instruments Tool (Leaks) and am receiving memory leaks in the QuartzCore library and don't know exactly where in my code this is occurring.我正在运行 Instruments Tool (Leaks) 并在 QuartzCore 库中收到QuartzCore泄漏,并且不知道我的代码中确切发生了这种情况。 Usually I'm able to pin point the line where the leak is occurring, however the instrument tool isn't giving me anywhere to view this type of information.通常我能够确定泄漏发生的位置,但是仪器工具没有让我在任何地方查看此类信息。

What would be some other things I could look at in terms of diagnosing such a leak?在诊断此类泄漏方面,我还可以查看哪些其他内容?

在此处输入图像描述

在此处输入图像描述

First, try running this on the device.首先,尝试在设备上运行它。 Sometimes the simulator will report leaks that do not exist on the device.有时模拟器会报告设备上不存在的泄漏。

Secondly, open up the stack trace (right sidebar) and see what code of yours might be involved higher up in triggering this call, then you can think from there why that code might be leaking.其次,打开堆栈跟踪(右侧边栏)并查看您的哪些代码可能在触发此调用时涉及到更高层,然后您可以从那里思考为什么该代码可能会泄漏。

One additional bit of advice.还有一点建议。 Instead of playing with leaks there, switch over to ObjectAlloc and use the Heapshot feature - if you know about where the leak is, use the heapshot to set a base memory measurement and every time you hit the "heapshot" button after that you'll see a kind of memory "diff" against that baseline you set.不要在那里玩泄漏,而是切换到 ObjectAlloc 并使用 Heapshot 功能 - 如果您知道泄漏在哪里,请使用 heapshot 设置基本 memory 测量值,然后每次点击“heapshot”按钮,您将根据您设置的基线查看一种 memory “差异”。 Solving any over-retained problems might also fix your leak.解决任何过度保留的问题也可能解决您的泄漏问题。

If you're only leaking 16 bytes at a time, it's really not likely to become an issue in your app.如果您一次只泄漏 16 个字节,那么它真的不太可能成为您的应用程序中的问题。 And if the leak is occurring in a system framework, it probably isn't your fault.如果泄漏发生在系统框架中,那可能不是你的错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM