iPhone应用程序NSNumber内存泄漏 [英] iphone app NSNumber memory leak

查看:135
本文介绍了iPhone应用程序NSNumber内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我内存泄漏,不知道它来自何处以及如何解决.

I'm having a memory leak and I have no clue where it comes from and how to fix it.

在某个时刻,我计算出两个位置之间的距离.

At some point i calculate the distance between 2 locations.

double calc = [self getDistance:location to:otherLocation];
NSNumber *distance = [NSNumber numberWithDouble:calc];

在仪器中,我作为泄漏对象NSCFNumber获得,它标识

in instruments i get as leaked object NSCFNumber and it identifies

NSNumber *distance = [NSNumber numberWithDouble:calc];

是导致此问题的行.

我很茫然.请帮忙.

先谢谢了, 米歇尔

推荐答案

您在此处所做的操作没有任何问题. NSNumber的保留计数为+0(已自动释放),因此您可能会将NSNumber保留在其他位置,而忘记释放它.

There's nothing wrong with what you're doing there. The NSNumber has a +0 retain count (autoreleased), so you're probably retaining that NSNumber somewhere else and forgetting to release it.

这篇关于iPhone应用程序NSNumber内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆