I am currently reading audio floats from a file using Dirac's (OSStatus) readFloatsConsecutive:(SInt64)numFrames intoArray:(float**)audio
function. I create a pointer of float **
arrayToFill = malloc(channelCount * sizeof(float*));
for(int i = 0; i < channelCount; ++i)
{
arrayToFill[i] = malloc(frameCount * sizeof(float));
}
and pass it to the Dirac function I get a massive memory spike when all the floats are malloced.
In instruments I get spikes that increase about 90MB, and for some reason this app still runs on the device.
would e.g. 15839544 * 2 number of floats cause these massive spikes?
How can it use so much memory? Is it virtual memory? I dont see any VM allocations.
I dont see how loading a single file of e.g. 5MB audio file can result in such massive spikes in memory.
Yes, absolutely. A float is 4 bytes, so two arrays of 15.8 million floats apiece is around 120 MB total.
As far as how you're ending up with this from a 5 MB input file: Audio compression is an amazing thing. :)