獲取 iphone 手機的總記憶體和可用的記憶體大小

2021-06-02 10:11:04 字數 1118 閱讀 3669

typedef struct uidevicememoryinfo  uidevicememoryinfo;

- (uidevicememoryinfo)memoryinfo 

mach_msg_type_number_t count = host_vm_info_count;

vm_statistics_data_t vmstat;

if (host_statistics(mach_host_self(), host_vm_info, (host_info_t)&vmstat, &count) != kern_success)

double total = vmstat.wire_count + vmstat.active_count + vmstat.inactive_count + vmstat.free_count;

// double wired = vmstat.wire_count / total;

// double active = vmstat.active_count / total;

// double inactive = vmstat.inactive_count / total;

// double free = vmstat.free_count / total;

mib[0] = ctl_hw;

mib[1] = hw_physmem;

length = sizeof(result);

if (sysctl(mib, 2, &result, &length, null, 0) < 0)

mib[0] = ctl_hw;

mib[1] = hw_usermem;

length = sizeof(result);

if (sysctl(mib, 2, &result, &length, null, 0) < 0)

uidevicememoryinfo info;

info.freememory = vmstat.free_count * pagesize;

info.totalmemory = total * pagesize;

return info;

}

獲取總記憶體?

activitymanager activitymanager activitymanager getsystemservice activity service activitymanager.memoryinfo memoryinfo new activitymanager.memoryinfo...

android 獲取手機記憶體大小

一 先說下非原創,拷貝的,寫上作個記錄,再自己加了些注釋。獲取手機記憶體大小 系統裡乙個檔案裡記錄著記憶體的大小,可以從那個檔案裡讀,檔名為meminfo return public string gettotalmemory initial memory integer.valueof array...

手機桌布獲取和判斷

對於是否為動態桌布的判斷方法 if the current wall is a live wall component,return the information about that wall otherwise,if it is a static image,simply return nul...