Menu Home

memory

Munging data four bytes at a time

void Munge32( void *data, uint32_t size ) { uint32_t *data32 = (uint32_t*) data; uint32_t *data32End = data32 + (size >> 2); /* Divide size by 4. */ uint8_t *data8 = (uint8_t*) data32End; uint8_t *data8End = data8 + (size & 0x00000003); /* Strip upper 30 bits. */ while( data32 != data32End […]

iOS:Get Memory Information

– (void)refreshMemoryInfo { uint64_t physicalMemorySize; uint64_t userMemorySize; int mib[2]; size_t length; mib[0] = CTL_HW; mib[1] = HW_MEMSIZE; length = sizeof(int64_t); sysctl(mib, 2, &physicalMemorySize, &length, NULL, 0); mib[1] = HW_USERMEM; length = sizeof(int64_t); sysctl(mib, 2, &userMemorySize, &length, NULL, 0); }

iOS:Max Memory Budget

iPad1: 127MB/256MB/49% (crash amount/total amount/percentage of total) iPad2: 275MB/512MB/53% iPad3: 645MB/1024MB/62% iPad4: 585MB/1024MB/57% (iOS 8.1) iPad Mini 1st Generation: 297MB/512MB/58% iPad Mini retina: 696MB/1024MB/68% (iOS 7.1) iPad Air: 697MB/1024MB/68% iPad Air 2: 1195MB/2048MB/58% iPod touch 4th gen: 130MB/256MB/51% (iOS 6.1.1) iPod touch 5th gen: 286MB/512MB/56% (iOS 7.0) iPhone4: 325MB/512MB/63% iPhone5: […]

Android:获取内存和进程信息

ActivityManager mAm = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE); private int getAppsRunning() { List<RunningAppProcessInfo> runningApps = mAm.getRunningAppProcesses(); return runningApps.size(); } private long getFreeMemory() { MemoryInfo mi = new MemoryInfo(); mAm.getMemoryInfo(mi); return mi.availMem; }