1 回答
TA贡献1890条经验 获得超9个赞
您的代码中没有内存泄漏。但是,您确实会保留大量内存,这就是您所看到的。
当我寻找任何类型的泄漏时,我更喜欢进行多次测试。这很容易通过您的代码完成。只需添加:
func init(){
for{
main()
}
}
新输出将显示在运行期间没有丢失内存:
Memory Acquired: 2885880
Memory Used : 14848
Memory Acquired: 2594885728
Memory Used : 297108312
Memory Acquired: 2594885728
Memory Used : 297108984
Memory Acquired: 2624143456
Memory Used : 297108312
Memory Acquired: 2624143456
Memory Used : 297108984
Memory Acquired: 2624143456
Memory Used : 297108312
Memory Acquired: 2624143456
Memory Used : 297108984
Memory Acquired: 2624143456
Memory Used : 297108312
Memory Acquired: 2624143456
Memory Used : 297108984
Memory Acquired: 2624143456
Memory Used : 297108312
- 1 回答
- 0 关注
- 214 浏览
添加回答
举报