我是iOS开发的新手,所以如果我的问题听起来不值得在stackoverfow上出现,我提前道歉。
我正在建立一个简单的游戏与家庭ViewController和游戏ViewController至于结构方面。
我已经添加了一个非常简单的函数来杀死活动,以确保没有留下任何东西,它在离开游戏ViewController之前被调用。下面是我使用的代码:
private func cleanThis(){
//removing objects from array
activeEnemies.removeAll()
//removing objects from array
activeTargets.removeAll()
//removing the rest
let subViews = self.view.subviews
for subview in subViews{
subview.removeFromSuperview()
}
}
我肯定在这里遗漏了什么,当我在没有进入主页的情况下测试它时,有一个38MB的恒定内存活动。我还没有想出如何监控ViewController中还剩下的内容。
任何帮助都是非常感谢的。
附注:当ViewController中没有对象时,内存活动应该是0,对吗?
转载请注明出处:http://www.jubohx.com/article/20230427/2338431.html