Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory still increasing when use CFRelease for ABRecordCopyValue?

Tags:

i have a problem make headache, i simply create method:

-(void) main{

      for (int i = 0; i< 100;i++) {
           [self getPhoneOfContact:i];
      }
 }

-(void)getPhoneOfContact:(NSInteger)id_contact {

     ABRecordRef record = ABAddressBookGetPersonWithRecordID(addressBook,id_contact);

     CFTypeRef ref1;
     ref1 = ABRecordCopyValue(record,kABPersonPhoneProperty);

     CFRelease(record);
     CFRelease(ref1); 
}

I think the memory will approximate constants because i have release memory copied, but in reality it still increasing for each loop i; who can explain me this :(. thanks!

like image 217
lemta Avatar asked Jan 20 '10 04:01

lemta


1 Answers

Your code is wrong. The ABAddressBookGetPersonWithRecordID call follows the Core Foundation 'Get Rule'. This means you do not have ownership of the return value and thus you do not have to release it.

See Core Foundation - Memory Management

like image 132
Stefan Arentz Avatar answered Oct 11 '22 17:10

Stefan Arentz