Post

Replies

Boosts

Views

Activity

Do we need to release the reference count on host port
Hi, I am using the below code to compute the free memory in iOS. uint64_t memAvailable() { mach_port_t host_port = mach_host_self(); if(host_port == MACH_PORT_NULL) { return 0; } vm_size_t pagesize; host_page_size(host_port, &pagesize); vm_statistics_data_t vm_stat; mach_msg_type_number_t host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t); if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) { tdlog(LOG_LEVEL_DEBUG, @"Failed to fetch vm statistics"); return 0; } /* Stats in bytes */ return vm_stat.free_count * pagesize; } My qs is do we need to call mach_port_deallocate() to release the reference count on host_port?? Please advise.
1
0
674
Mar ’23
Detect if NFC is enabled or not
Hi, I am using the below code to detect if NFC is enabled or not. (BOOL)isNFCAvailable { if ([NFCNDEFReaderSession readingAvailable]) { return YES; } return NO; } I have also added the permission is info.plist file NFCReaderUsageDescription Detecting if NFC is enabled or not I am testing on iphone XS with ios 15.6.1 and on iphone 11 with ios 13.2.2. In both the cases, the API is returning false. Can you please let me know if I am missing something.
0
0
772
May ’23