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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:49:07+00:00 2026-06-04T07:49:07+00:00

I am developing an iPhone application which has a module written in C and

  • 0

I am developing an iPhone application which has a module written in C and Objective C.
I am using pthread_create for creating new thread.
For memory allocation, i have used malloc().

  1. Will NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]
    handle this memory? Or should i explicitly use free() to release this memory?

    The thread is running continuously and it is allocating lot of memory. So after one point, it gives memory warning.

  2. Will it create problem if i explicitly free the memory as well as i use NSAutoreleasePool?

  3. Is there any way to check the memory leaks in this thread. Xcode’s profile tool is used to check memory leaks in objective C code. will it help to manage C type memory allocation?

Please help me out.

  • 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-04T07:49:08+00:00Added an answer on June 4, 2026 at 7:49 am

    Will NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init] handle this memory? Or should i explicitly use free() to release this memory?

    you should use free for all memory allocated through malloc

    Will it create problem if i explicitly free the memory as well as i use NSAutoreleasePool?

    none. you have to do that as well.

    Is there any way to check the memory leaks in this thread. Xcode’s profile tool is used to check memory leaks in objective C code. will it help to manage C type memory allocation?

    as far as I understand, Instruments Leaks is tightly related to the ObjC runtime system, so it does not work for memory directly (meaning, not via the ObjC runtime) allocated through malloc. For MacOSX, Apple provides a couple of tools to detect memory leaks (MallocDebug and leaks, see here), but they do not work for iOS apps. You might try to run them against the simulator, but I suspect they would not give you reliable results.

    On the other hand, if you are using a plain-C library, then you might build around it a plain-C testbed derived from your overall code (by removing the iOS specific parts) to be able to check it under MacOSX. The testbed would emulate the kind of workflow of your app with the C-only module. This would be a significant effort, though, and I would go for it only if you are really worried about it.

    Another approach you have is building and ObjC wrapper around your C module, so that you have one or more classes that use the C module and allocate/release memory for it through malloc/free in the init/dealloc methods; you could check that your ObjC wrapper objects are not leaked by using Instruments and if you have correctly implemented the wrapper objects you could be pretty sure that you are not leaking malloc memory.

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

Sidebar

Related Questions

I am developing an Iphone application in which i am using GoogleAPI to find
I am developing an iphone application which has some facebook integration in it.I added
I am developing an iPhone application which has a lot of different cards, each
I am developing an iPhone application using Objective-C. I want to access a data
I am developing iPhone application which is using the 3 projects. One project is
I am new to iPhone apps, I am developing one application which requires playing
I have developing an iPhone application using xcode 4 which is compatible with iOS
I am developing an iPhone application in which I am fetching data from a
I am developing an iPhone application in which I am loading lots of data
I am developing an iPhone application in which I want to show nearest restaurants

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.