Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone app NSNumber memory leak

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];

in instruments i get as leaked object NSCFNumber and it identifies

NSNumber *distance = [NSNumber numberWithDouble:calc];

as the line causing this.

I'm at a loss. Please help.

thanks in advance, Michiel

like image 499
McDJ Avatar asked Jan 21 '26 01:01

McDJ


2 Answers

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.

like image 160
Dave DeLong Avatar answered Jan 23 '26 13:01

Dave DeLong


Leaks shows you where an object that is leaking is CREATED.

If you think about it, there's really nothing else Leaks can show you - it's leaking because the object should have been released at some point, and Leaks can't show you code that does not exist!

like image 25
Kendall Helmstetter Gelner Avatar answered Jan 23 '26 13:01

Kendall Helmstetter Gelner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!