正如我从苹果文档中了解到的那样,在 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 .
最常见的情况之一是类实例之间存在强引用循环,因为编译器不知道何时释放那部分内存。另请查看 strong
和 weak
引用的区别。
但正如 Apple 所说,“在大多数情况下”,没有它应该没问题,但如果你的应用程序崩溃,则可能是你有内存问题。
关于ios - 当 ARC 在 iOS 中出现时,我们是否还需要使用 xcode 工具(Allocations 和 Leak)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31432204/