Swift 的自动引用计数和 Python 的(手动)引用计数有什么区别?
是不是因为Swift支持weak var
自动清理循环数据结构,而Python中没有这个东西,必须手动del
,否则内存泄漏?
最佳答案
Swift ARC(自动引用计数),根据苹果
Swift uses Automatic Reference Counting (ARC) to track and manage your app’s memory usage. ARC automatically frees up the memory used by class instances when those instances are no longer needed.
当引用计数等于 0 时,Swift 将删除对象。
Python使用垃圾收集器
关于python - Swift/Python 引用计数差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56844255/