If I use malloc along with Automatic Reference Counting, do I still have to manually free the memory?
int a[100];
int *b = malloc(sizeof(int) * 100);
free(b);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Yes, you have to code the call to
freeyourself. However, your pointer may participate in the reference counting system indirectly if you put it in an instance of a reference-counted object:There is no way around writing that call to
free– one way or the other, you have to have it in your code.