0

I'm trying to use malloc to create some memory for an audio buffer for Remote IO. It works the vast most of the time. But recently it's been crashing on some iOS 6.0.1 through 6.1.3, strangely on iPhone 5 and iPad 3-4, iPad 3-5, and iPad 3-6.

The size of the buffer is below. Isn't it odd that the higher performance devices would crash on this? Is it because they're used more aggressively?

My thought on how to fix it, is to trap this attempt with a catch, and then on error try half the size. This normally provides for 30 seconds of "listening" through the mic.

THANKS!!

Ron

int num_transfer_buffer_samples = 655350; 

transferBuffer = malloc((num_transfer_buffer_samples) * sizeof(float)); // CRASH
Alistair
  • 101
  • 10
  • 1
    That looks like a *lot* of memory. Double-check your math? – Randy Howard Apr 07 '13 at 06:41
  • It's really supposed to be `655350`, and not `65535`? – Nate Apr 07 '13 at 08:00
  • Yes, well the sample rate is 22050.0. That's twenty two thousand samples per second. 22050 * 30 seconds = 655350. Maybe that is too much memory! Maybe a kinder way would be to save to the disk during pauses. – Alistair Apr 07 '13 at 08:46
  • Yes, really - that's how much it's been using. Why is that way too much? – Alistair Apr 07 '13 at 19:07
  • That comes out to about 2.49 MB, nothing the high performance devices can't handle. Could there be a leak with these allocations or elsewhere? Are you running in Zombie mode? – Anurag Apr 08 '13 at 01:55

0 Answers0