iPhone:我应该使用“仪器”吗?验证内存泄漏?

发布于 2024-09-26 06:35:42 字数 111 浏览 3 评论 0原文

我只是通过长时间的测试(几个小时)来“即兴发挥”它,没有崩溃,并且观察了我的代码很长一段时间,并确保就内存泄漏而言,一切看起来都非常干净。但是我应该使用乐器吗...在上传到应用程序商店之前是否必须执行此操作?

I've just kind of been 'winging' it with long tests (for hours) with no crashes, and eyeballing my code for quite a while and made sure that everything looks pretty kosher as far as memory leaks. But should I be using instruments... is it mandatory to do this before uploading to app store?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

九公里浅绿 2024-10-03 06:35:42

我认为使用 Instruments 不仅是一种好的实践,而且是整个 iOS 开发社区强烈推荐的。即使您的应用程序看起来运行良好,但在其他用例中仍然可能会出现泄漏。在将您的应用程序推送到 App Store 之前,请使用 Instruments 彻底测试您的应用程序,否则您可能会遇到许多使用旧一代设备的用户抱怨应用程序崩溃的情况。

一些最关键工具

泄漏

分配

时间分析器

使用 Instruments 的另一个建议是使用 < a href="http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Warning-Options.html" rel="nofollow">-pedantic 标志。

I think that using Instruments is not only good practice, it's strongly recommended by the iOS development community as a whole. Even if your app seems to run fine, you still may have leaks in other use cases. Test your app thoroughly with Instruments before pushing to the App Store or you may be in for a lot of users on older generation devices complaining that the app crashes.

Some of the most crucial tools:

Leaks

Allocations

Time Profiler

Another suggestion alongside using Instruments is to compile with the -pedantic flag.

沉溺在你眼里的海 2024-10-03 06:35:42

除了Yuji所说的之外,在构建设置中打开尽可能多的警告,默认情况下这些警告是关闭的。

In addition to what Yuji said, turn on as many warnings as you can in the build settings, by default these are off.

去了角落 2024-10-03 06:35:42

不,

但至少在 XCode 中运行“构建和分析”。它告诉您只需静态分析源代码就可以找到有关内存泄漏的信息。它基本上是由机器观察代码。这比自己做要好得多。如果发出任何警告,请修复所有警告。静态分析器很少给出误报。

此外,使用 Instruments 运行您的应用程序有助于了解它如何真正分配内存。有时也很有趣。

No.

But at least run "Build & Analyze" in the XCode. It tells you what it can find about the memory leaks, just by analyzing the source code statically. It's basically eye-balling the code by the machine. It's infinitely better than doing that yourself. If there're any warnings issued, fix all of them. It's rare for the static analyzer to give false positives.

Also, running your app with Instruments is helpful to see how it really allocates memories. Sometimes it's fun, too.

冷清清 2024-10-03 06:35:42

如果不运行 Instrument 的泄漏工具,我永远不会发布应用程序。
我经常错过某个地方的发布。即使我读了 200 遍代码,如果没有 Instruments,我也找不到它。

I would never publish an app without running Instrument's leak tool.
I often miss a release somewhere. And even if I read the code 200 times I would not find it without Instruments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文