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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:31:14+00:00 2026-06-03T06:31:14+00:00

Sorry for the many posts here regarding this issue but i am having a

  • 0

Sorry for the many posts here regarding this issue but i am having a progress here.

I have a callback function, which is in C , and been called when a new buffer is arrived.

I was told here to not do ANYTHING in that callback ,not malloc , or anything .

Now i want to send my new buffer to another class( which will create a circle buffer and save many buffers).

BUT, the basic thing that i dont get, is that if i call another function from the callback – its the same as doing it in there- becuase in that function i do the DSP and it takes time, so its the same as doing it in that callback- because its in serial.

froof :
i am sending the data to another function in another class, and its ok, but if i try to NSLOG it in there, i AGAIN have this memory leaks.

here is the other class that i call from the callback :

    - (id)init 
    {
        self = [super init];
        if (self)

        {
            data = malloc (sizeof(SInt16) * 4000);


        }
        return self;
    }

 -(void)sendNewBuffer:(SInt16*)buffer
    {

        data=buffer;

        NSLog(@"data arrived size is : %lu",sizeof(data));
        for(int i=0; i<sizeof(data);i++)
        {
            NSLog(@"%d",data[i]);
        }

    }

ONLY when comment the log, it works without memory leaks.
that means the callback is waiting for that !

How would i process that data somwhere else in parallel ?
i am spending a week for that now.

thanks.

  • 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-03T06:31:16+00:00Added an answer on June 3, 2026 at 6:31 am

    One possibility for the memory leak when using Objective-C objects such as the NSString in the NSLog is that those objects may be autoreleased (or may internally used autoreleased objects).

    Your callback may be called from a different thread. You can confirm this by putting a breakpoint in the callback and looking in the debugger if this is the main thread or a secondary thread.

    Any secondary thread must have its own AutoRelease pool. The system creates one automatically for the main thread, but you must create one explicitly if you are to create a secondary thread.

    Also, one reason for not allocating stuff in a callback is usually for performances. Often the callback needs to be kept at minimum to avoid blocking the thread that called it.

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

Sidebar

Related Questions

Sorry if this has been asked, my search brought up many off topic posts.
I am sorry if this has been posted before. I have searched many websites
Sorry if this is a newbie question. I have searched but found nothing... Using
Sorry I'm asking too many questions in a row. I have a list of
Sorry, I'm sure this is simple but I'm tired and can't figure it out.
Sorry for the length of this post, but at the moment we are clueless,
This is not the clearest of question titles, sorry about that, but I will
First of all... Sorry for this post. I know that there are many many
Sorry for the long post, but this forum always asks for use cases :-).
It has been a long question, so here is the summary first, I have

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.