简体   繁体   English

如果从数组中删除某些内容,它会从内存中释放吗?

[英]If you remove something from an Array, will it get released from memory?

Assuming that nothing is referencing it anymore, will an object be released from memory after being removed from an array? 假设不再有任何引用,将对象从数组中删除后是否将其从内存中释放出来?

Should I set it to nil before removing it? 我应该在删除它之前将其设置为nil吗?

Yes it will be released, Swift uses ARC . 是的,它将被发布,Swift使用ARC If an object is added to an array and then removed. 如果将对象添加到数组然后删除。 It will be cleared from memory. 它将从内存中清除。 You will not need to it to nil before removing. 删除之前,无需将其设置为零。

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

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