ios - 当 ARC 在 iOS 中出现时,我们是否还需要使用 xcode 工具(Allocations 和 Leak)?

标签 ios swift memory-management automatic-ref-counting xcode-instruments

正如我从苹果文档中了解到的那样,在 iOS 中,ARC 将自动处理内存泄漏和内存管理。

但我的疑问是,我们是否还需要 Xcode 工具(Allocations 和 Leak)的作用来确保我们的应用程序是否发生了内存泄漏?

如果您知道解决方案,请分享。

最佳答案

是的,当然你需要使用Intruments。

Swift uses Automatic Reference Counting (ARC) to track and manage your app’s memory usage. In most cases, this means that memory management “just works” in Swift, and you do not need to think about memory management yourself. ARC automatically frees up the memory used by class instances when those instances are no longer needed.

However, in a few cases ARC requires more information about the relationships between parts of your code in order to manage memory for you. This chapter describes those situations and shows how you enable ARC to manage all of your app’s memory.

你应该看看Automated Reference Counting .

最常见的情况之一是类实例之间存在强引用循环,因为编译器不知道何时释放那部分内存。另请查看 strongweak 引用的区别。

但正如 Apple 所说,“在大多数情况下”,没有它应该没问题,但如果你的应用程序崩溃,则可能是你有内存问题。

关于ios - 当 ARC 在 iOS 中出现时,我们是否还需要使用 xcode 工具(Allocations 和 Leak)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31432204/

相关文章:

ios - 难以在 Xcode 中归档静态库(未找到)

swift - 如何快速获取 iOS 中 Google Drive 中 GTLDriveFile 的修改日期?

ios - 如何在没有苹果开发者帐户的情况下从 xcode 项目导出 ad-hoc .ipa

java - javacore 和 heapdump 中的堆大小 : 20x difference on IBM JVM

java - 将全局静态变量声明为 null 是一个好习惯吗?

ios - 在 iPad Pro 中不工作的单个 UIViewController 上禁用自动旋转

ios - 在 StoryBoard iOS 中将 UIContainerveiw 添加到 SlideViewNavigation 时出现问题

ios - 添加新项目后 UITableView 未更新(使用核心数据)

ios - 新 Alamofire Swift 3 上的 GET 请求

c++ - 奇怪的内存行为 - C++