我正在制作演示,但我发现当我从相机拍照时内存会增加。所以一定有东西导致内存泄漏。我怎样才能检查它在哪里?
以下是我写的示例代码:
https://github.com/AarioAi/NotesOpen/tree/master/Swift/10.1.1%20Photo%20-%20Avatar
效果视频:
https://www.facebook.com/AarioAi/videos/vb.100011236983846/179251062459459/?type=2&theater
答案 0 :(得分:1)
class Counsel {
let bias:String = "Bias"
var scale: Void -> String? = {
return "Scale bias"
}
deinit {
print("deinit")
}
}
do {
var counsel:Counsel? = Counsel()
counsel = nil
}
按照预期在操场上打印deinit。看,deinit被称为
class Counsel {
let bias:String = "Bias"
var scale: Void -> String? = {
return "Scale bias"
}
deinit {
print("deinit")
}
}
do {
var counsel:Counsel? = Counsel()
counsel = nil
print("still in scope")
}
/*
deinit
still in scope
*/