I have a bit off code that manipulates Audio files by first putting all the audio file data in NSData variables. But it crashes sometimes because it uses to much RAM
NSData *data1 = [NSData dataWithContentsOfFile: someFile];
I have checked using Instruments that everything was being released and how the RAM was being used and I figured out that it just crashes sometimes when the audio file are to big. Is there a way to store data in smaller bits or in the flash or any other way which would allow me to work with big files without exceeding the maximum RAM on the iPhone.
One thing Im using the NSData for example is concatenating 2 files like this:
[data1 appendData: data2];
Thanks
of course. the problem is more fundamental than
NSData– you don’t usually load a set of audio files (in their entirety) into memory, especially when the device has very little memory. it’s atypical to load the entire file even on osx, where you can have plenty of memory (unless the file is known to be very small). this is why the audio file apis allow you to read and write in blocks (ref:ExtAudioFileReadorAudioFileReadPackets).