Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9208979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:44:05+00:00 2026-06-18T00:44:05+00:00

EDIT : Updated my device (and deployment target) from iOS 4.3.5 to iOS 5.1.1

  • 0

EDIT: Updated my device (and deployment target) from iOS 4.3.5 to iOS 5.1.1 and still has the same issue

Having a problem releasing a class member AVAudioPlayer to play another sound after playing a sound.

This only seems to be a problem on one of my devices, a 3rd generation iPod Touch running iOS 4.3.5/5.1.1.

My 4th and 5th generation devices running iOS 6 run just fine.

;
audio = nil;
@try
{
    audio = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
    if ((audio != nil) && (!error))
    {
        audio.delegate = (id)self;
        audio.volume = gVolume/10;
        ;
    }
    else
    {
        ;
        audio = nil;
    }
}
@catch (NSException *exception)
{
    ;
    audio = nil;
}

First time through it plays just fine, but when this code executes a second time to play another sound, it gives an EXC_BAD_ACCESS error, which does not happen on my 4th/5th generation devices.

I purposely delay the release until I need to play another sound in order to give the play time to perform.

Tried working with AVAudioPlayerDelegate but that didn’t solve the problem, nor does calling:

;

I do initialize audio to nil in viewDidLoad, and clean up in viewDidUnload and dealloc.

Was having a lot of memory leak issues but this version of the code seemed to have solved that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:44:07+00:00Added an answer on June 18, 2026 at 12:44 am

    Thanks to the comment above, and the failure of all my other ideas, I went ahead and took advantage of ARC.

    I didn’t want to refactor my entire project to start using ARC, so I rewrote a new class to handle all of my audio needs and set some compiler flags (-fobjc-arc) to enable ARC just for that file.

    Not exactly sure what I was doing wrong before, but the system seems to be much better at managing memory than I am, and I’m happy to let it solve all my problems.

    EDIT 2:

    Apparently Apple did finally fix their memory leak so I went back to my ARC solution which works fine for both iOS 5 and iOS 6.

    EDIT:

    I may have been a little premature.

    While implementing ARC for this was helpful in general, this specific problem goes deeper.

    Apparently, there is a leak in Core Foundation for iOS 6.

    Leak from NSURL and AVAudioPlayer using ARC

    Memory Leak – NSString & NSURL

    Using ARC, it works fine on my Gen 3 iOS 5 device, but leaks significantly for Gen 4/5 iOS 6.

    Without ARC, Gen 4/5 iOS 6 works fine, but Gen 3 iOS 5 crashes.

    I ended up making two versions of my new class, one using ARC and one not, and checking the system version at runtime [[UIDevice currentDevice] systemVersion] to determine which version to use.

    It may be a little clumsy, but does allow me to support the Gen 3 devices. If Apple ever fixes their problem I can return to a single version at that time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Updated with suggestions from Bill Karwin below. Still very slow. I'm trying to
Edit 1/16/2013: Problem Resolved! Two days ago, I released an updated version of the
EDIT: Was a hardware problem.....getting a duplicate device or cable seemed to solve the
Edit (updated question) I have a simple C program: // it is not important
I register the following function //EDIT: updated $("#id").on("change", function() { alert('xxx'); }); In my
This is pretty straight forward. EDIT: Updated question and added fourth echo. Here is
EDIT : Scroll down to see the updated code. I would like to build
See updated input and output data at Edit-1. What I am trying to accomplish
I'm have a widget that is being updated from a service. When the user
I'm working with an API that only has POST calls. Create, edit, and delete.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.