編輯:關於Android編程
1) 在kernel log中,可以看到被從內核中挖出去的CMA區域大小
<6>[ 0.000000] Machine: Qualcomm Technologies, Inc. MSM 8916 MTP <6>[ 0.000000] cma: Found external_image__region@0, memory base 0x0000000086000000, size 8 MiB, limit 0xffffffffffffffff <6>[ 0.000000] cma: Found modem_adsp_region@0, memory base 0x0000000086800000, size 85 MiB, limit 0xffffffffffffffff <6>[ 0.000000] cma: Found pheripheral_region@0, memory base 0x000000008bd00000, size 6 MiB, limit 0xffffffffff ffffff <6>[ 0.000000] cma: Found secure_region@0, memory base 0x0000000000000000, size 109 MiB, limit 0xffffffffffffffff <6>[ 0.000000] cma: Found venus_qseecom_region@0, memory base 0x0000000000000000, size 18 MiB, limit 0x0000000090000000 <6>[ 0.000000] cma: Found audio_region@0, memory base 0x0000000000000000, size 3 MiB, limit 0xffffffffffffffff
2) 打印/proc/meminfo的內容,以下是一個打印的例子
? MemTotal ? 921600 kB
? MemFree ? 138728 kB
? Buffers ? 4616 kB
? Cached ? 362008 kB
3) 被挖出去的Non-HLOS的內存大小是
Non-HLOS memory = 8 MB + 85 MB + 6 MB = 99 MB
這個大小就是上面挖出去的CMA區域中,被固定從內存中挖出去的幾個區域的綜合。
4) HLOS也可以說是Android Memory的大小 = MemTotal = 900MB
5) kernel占據的大小 = Total Ram - Non-HLOS 內存大小 - HLOS或者Android Memory大小 - (被另外Carveout的內存,上面的內容裡邊是不存在這種被另外Carveout的內存)
所以kernel占據的大小 = 1025MB - 99MB - 900MB - 0MB = 25MB
6) Free memory計算
Free memory = MemFree(/pro/meminfo打印出來的) + Cached(/pro/meminfo打印出來的) = 138728 kB + 362008 kB ~=489MB
7) 計算APP + Framework和APPs + framework 內存大小 = HLOS或者Android memory大小 - free memory = 900MB -489MB = 411MB
To get overall memory footprint , use the following commands:
adb shell cat /proc/meminfo
adb shell /proc/iomem
adb shell procrank
adb shell procrank – C
adb shell cat /proc/zoneinfo
adb shell dumpsys meminfo
adb shell dumpsys SurfaceFlinger
(Run the above command after collecting the above, as the dumpsys is known to trigger GC,
which can cause some variation in the data).
Use the following command to get the details of zram configuration and copy t he zram folder
to logs location:
adb shell cat /proc/swaps
adb pull /sys/block/zram0/ zram
If there are multiple zram devices (zram1, zram2, and so on ), get all such information. To
know KSM savings, use the following set of commands and share the ksm folder :
mount –t debugfs none /sys/kernel/debug
adb pull /sys/kernel/mm/ksm/ ksm
To get process specific memory footprint, use the following commands
adb shell procmem process_pid
adb shell dumpsys meminfo process_pid
adb shell cat /proc/ process_pid/smaps
adb shell dumpsys procstat process_pid
To know all the vm settings, use the following command:
adb shell cat /proc/sys/vm/*
To get LMK parameters , use the following commands:
adb shell cat /sys/module/lowmemorykiller/parameters/adj
adb shell cat /sys/module/lowmemorykiller/parameters/minfree
To understand buffer allocations in kernel , use the following command:
nm - t d -l - r –size- sort - S vmlinux | head -50
To know KGSL allocations, use the following set of commands and share kgsl folder :
mount –t debugfs none /sys/kernel/debug
adb pull /sys/class/kgsl/kgsl/ kgsl
Share the build.prop file from your device :
adb pull /system/build.prop
Every application has the following included as part of its memory consumption
? Uncached memory
? Cached memory
? KGSL memory
? ION memory
All QC provided process memory numbers using “dumpsys meminfo” include all the above.
Other vendors may not include KGSL and ION memory. Our representation to include kgsl and
ion is per Google’s recommendation. It is implemented in the memtrack hardware module
(/system/lib/hw/memtrack.msm8916.so) as part of our solution and exposed to upper layers (like
dumpsys, meminfo , an d so on).
這裡畫了個餅圖的變種,具有分割突出效果的餅圖(Pie Chart),就是個切蛋糕效果的餅圖,畫這種圖,其技巧就在於圓心的偏移。 在圓心偏移,半徑不變的基礎上,效果就出來了
本教程為大家分享了Android毛玻璃效果的具體代碼,供大家參考,具體內容如下BlurimageActivity.java代碼:package com.siso.craz
在啟動Android應用時, 直接顯示頁面, 就稱之為冷啟動(Cold Start). 為了增強用戶體驗, 可以添加控件動畫, 讓啟動頁面更有趣, 用戶也更加容易接受.
Android源代碼在編譯之前,要先對編譯環境進行初始化,其中最主要就是指定編譯的類型和目標設備的型號。Android的編譯類型主要有eng、userdebug和user