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

  • SEARCH
  • Home
  • 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 7503765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:20:42+00:00 2026-05-29T21:20:42+00:00

I’m handling RemoteIO to get mic inputs and modify them little. Sometimes it crashes

  • 0

I’m handling RemoteIO to get mic inputs and modify them little.

Sometimes it crashes with EXC_BAD_ACCESS and there is no more message.

The lines that make crashes are these;

  int currPower = [[powers objectAtIndex:i] intValue];
  int prevPower = [[powers objectAtIndex:i - 1] intValue];

explaining the code,

  1. “powers” is NSMutableArray.
  2. [powers count] was always bigger than variable “i”

Struggling for a while, I found a good way to fix it.

A environment variables.

So I set NSZombieEnabled and also NSDebugEnabled so that I could see the reason of the crashes.

But even though I set the variables, Xcode shows no message.
(But it correctly shows messages when a crash occurs from other line.)

Also a weird thing is that it doesn’t crash just after the start of run;
it crashes in a minute in average. (But the times really varied.)

And this is a little guess. When I decreased the rate to half than before,
it was more stable.

So, is it a problem with NSMutableArray, because NSMutableArray method couldn’t catch up the speed of the rate?

or do you see some other possible reasons?

=========================================================================================

There are some more codes.
I allocated powers in this way..

  powers = [[NSMutableArray alloc] initWithCapacity:POWER_ARRAY_SIZE];

where I release the powers array is..

  - (void)dealloc {
     [powers release];
     [super dealloc];
  }

and no where else.

more detailed code is this.

  - (void)drawRect:(CGRect)rect
  { 
     ...//Do Something
     ...//Check "endindex" and "startindex" not to exceed boundary

     for (int i = endindex; i > startindex; i-=1)
     {

        int currPower = [[powers objectAtIndex:i] intValue];
        int prevPower = [[powers objectAtIndex:i - 1] intValue];

        ...//Doing something

     }
  }

this drawRect: method is calling from Main Thread(By Timer) in every millisecond.

—
updating(more specifically adding) powers in this method

  - (void)setPower:(int)p
  {

     [powers addObject:[NSNumber numberWithInt:p]]; 

     while ([powers count] > POWER_ARRAY_SIZE){
        [powers removeObjectAtIndex:0];
     }
  }

and also this method is calling in every millisecond.
and this is calling in background thread.

so without @autoreleasepool XCode Shows message of alert of leaking

for this reason I blocked the method(setPower) with @autoreleasepool{..}

  • 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-05-29T21:20:43+00:00Added an answer on May 29, 2026 at 9:20 pm

    I found the answer.

    Crashes are occurred because NSMutableArray of objected-C sometimes ack wrong.

    That’s when I try to do something in every milliseconds with it.

    So I changed the Objective-C array to C array, like

      int power[ARRAYSIZE];
    

    and after I changed it, it works fine.

    May be NSMutableArray isn’t that light to do something really fast.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
In my XML file chapters tag has more chapter tag.i need to display chapters
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.