my program works fine but the memory occupation is expending rapidly, i've debug for a long time and found such a problem:
if (some_condition)
{
NSMutableArray *fftArray256 = [NSMutableArray array];
NSMutableArray *fftArray = [NSMutableArray array];
[ESUtils changeToFFTData:pDatas outData:fftArray];//some data will be inserted in the fftArray.
for(NSNumber *n in fftArray)
{
double d = [n doubleValue];
d *= 256;//change the scale
[fftArray256 addObject:[NSNumber numberWithDouble:d]];
}
fftObj.degree = [self getDegree:fftArray256];
[fftArray256 removeAllObjects];
[fftArray removeAllObjects];
}
if i replace
[fftArray256 addObject:[NSNumber numberWithDouble:d]];
with
[fftArray256 addObject:@"1"];
everything will be fine, memory will grow before the last two lines, but after that all memory will be released.
if not changing like above the memory occupation will grow after leaving this block, it will repeat endlessly till the program fails. the removeAllObjects method could release part memory but remains a major part in memory, even after leaving this block.
so what's the problem with the [NSNumber numberWithDouble:d]? how can i release them totally before i leave this block?
i know it's not making sense, or I won't ask...