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 7840145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:40:27+00:00 2026-06-02T15:40:27+00:00

I have a code that we use many times with our apps, its a

  • 0

I have a code that we use many times with our apps, its a class that take the buffer samples and process it ,then send back notification to the main class.
The code is c and objective-c.

It works just great, but there is a memory growing which i can see in instruments-allocations tool. the “overall bytes” is keep growing, in 100k a second. becuase of some parts of the code that i know who they are .

this is the callback function, with the line that makes problems.
it happens many times a second.
I also dont really understand where to put my *pool :

    static OSStatus recordingCallback(void *inRefCon, 
                                      AudioUnitRenderActionFlags *ioActionFlags, 
                                      const AudioTimeStamp *inTimeStamp, 
                                      UInt32 inBusNumber, 
                                      UInt32 inNumberFrames, 
                                      AudioBufferList *ioData)
    {

        AudioBuffer buffer;
        buffer.mNumberChannels = 1;
        buffer.mDataByteSize = inNumberFrames * 2;
        //NSLog(@"%ld",inNumberFrames);
        buffer.mData = malloc( inNumberFrames * 2 );
        // Put buffer in a AudioBufferList
        AudioBufferList bufferList;
        bufferList.mNumberBuffers = 1;
        bufferList.mBuffers[0] = buffer;


        // block A
        OSStatus status;
        status = AudioUnitRender(audioUnit, 
                                 ioActionFlags, 
                                 inTimeStamp, 
                                 inBusNumber, 
                                 inNumberFrames, 
                                 &bufferList); 

       //end block A

         NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
        int16_t *q = (int16_t *)(&bufferList)->mBuffers[0].mData;
        int16_t average ;

        for(int i=0; i < inNumberFrames; i++)
        {


            average=q[i];   

            if(average>100) // lineB 
                reducer++;

           //blockC
            if(reducer==150 )
            {

                average= preSignal + alpha*(average-preSignal);
                //NSLog(@"average:%d",average);

                //call scene
                [dict setObject:[NSNumber numberWithInt:average] forKey:@"amp" ] ;
                [[NSNotificationCenter defaultCenter] postNotificationName:@"DigitalArrived" object:nil userInfo:dict];
                reducer=0;
                preSignal=average;

            }
//end blockC

        }


         free(buffer.mData);
         [pool release];
        return noErr;


}

OK:
ignore blockC for a second.
removing blockA and lineB solve it all.
removing only one of them- leaks.

i just cant undetstand what is growing here .

  • 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-02T15:40:29+00:00Added an answer on June 2, 2026 at 3:40 pm

    Just a guess, but allocating a new NSAutoreleasePool inside of your recording callback function (which is a super time-critical function) is probably a bad idea.

    Actually, why are you doing this here at all? Shouldn’t you just have one pool for the entire app, in your main.m? This is probably causing some of your leaks.

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

Sidebar

Related Questions

I have following code snippet that i use to compile class at the run
hello I have this code that use to sort a datatable. Dim sortingIndex As
I have some code that I use in both my Worker Role and Web
I have a Perl code that use threads and HTTP::Async with multiple outbound IP
I'm moving an application to use the Spring3 framework and I have code that
I'm getting an error when I use the SharpZipLib. I have code that looks
I have a code that sets a new repeating alarm (on production I'll use
I have some cross platform DNS client code that I use for doing end
I have several blocks of the following code that each use there own matrix.
We have several sites that use Forms Based authentication (FBA) within SharePoint. Many of

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.