如何分析android log

发布网友 发布时间:2022-04-22 07:44

我来回答

1个回答

热心网友 时间:2022-06-17 23:14

一、分析前的准备工作
1. 查看内存

[ruby] view plaincopy
#cat /proc/meminfo
MemTotal: 9030 kB //总计物理内存的大小
MemFree: 455024 kB //可用内存有多少
Buffers: 10928 kB //磁盘缓存内存的大小
Cached: 1004 kB
SwapCached: 0 kB
Active: 184708 kB
Inactive: 1585 kB
Active(anon): 1433 kB
Inactive(anon): 244 kB
Active(file): 41344 kB
Inactive(file): 158320 kB
Unevictable: 0 kB
Mlocked: 0 kB
HighTotal: 1558 kB
HighFree: 304 kB
LowTotal: 747992 kB
LowFree: 454720 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 143332 kB
Mapped: 61624 kB
Shmem: 276 kB
Slab: 12776 kB
SReclaimable: 5040 kB
SUnreclaim: 7736 kB
KernelStack: 5128 kB
PageTables: 9012 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 451820 kB
Committed_AS: 79772 kB
VmallocTotal: 122880 kB
VmallocUsed: 49792 kB
VmallocChunk: 46020 kB

2. 查看进程信息,能够实时显示系统中各个进程的资源占用状况,类似于 Windows 的任务管理器

[ruby] view plaincopy
#top -n 1 -d 1 -m 30 -t
User 13%, System 10%, IOW 0%, IRQ 0%
User 22 + Nice 9 + Sys 24 + Idle 170 + IOW 0 + IRQ 0 + SIRQ 1 = 226

PID TID PR CPU% S VSS RSS PCY UID Thread Proc
1762 1762 0 5% R 12K 6K root top top
1323 1340 0 3% S 676928K 43096K bg u0_a55 MMHandlerThread com.tencent.mm
9 9 1 2% S 0K 0K root ksoftirqd/1
1323 1325 0 1% S 676928K 43096K bg u0_a55 GC com.tencent.mm
583 737 1 0% S 667232K 30480K fg u0_a44 droid.phasebeam com.android.phasebeam
298 326 1 0% S 728032K 45172K fg system ActivityManager system_server
298 321 0 0% S 728032K 45172K fg system SensorService system_server
960 960 0 0% S 661188K 33004K fg u0_a55 tencent.mm:push com.tencent.mm:push
843 843 1 0% S 660692K 38672K fg u0_a52 ndroid.systemui com.android.systemui
84 250 1 0% S 62188K 5688K fg system VSyncThread /system/bin/surfaceflinger
583 749 1 0% S 667232K 30480K fg u0_a44 droid.phasebeam com.android.phasebeam
960 984 0 0% S 661188K 33004K fg u0_a55 MMHandlerThread com.tencent.mm:push
22 22 0 0% S 0K 0K root kinteractiveup
84 84 1 0% S 62188K 5688K fg system surfaceflinger /system/bin/surfaceflinger
84 253 1 0% S 62188K 5688K fg system Binder_1 /system/bin/surfaceflinger
1143 1528 0 0% S 665552K 33132K bg u0_a23 AirPlayServer com.waxrain.airplayer
84 245 1 0% S 62188K 5688K fg system SurfaceFlinger /system/bin/surfaceflinger
53 53 0 0% S 0K 0K root rknand_buffer
1323 1323 0 0% S 676928K 43096K bg u0_a55 com.tencent.mm com.tencent.mm
298 637 0 0% S 728032K 45172K fg system Binder_4 system_server
298 7 0 0% S 728032K 45172K fg system Binder_5 system_server
1323 1330 0 0% S 676928K 43096K bg u0_a55 Compiler com.tencent.mm
84 8 0 0% S 62188K 5688K fg system Binder_3 /system/bin/surfaceflinger
298 304 1 0% S 728032K 45172K fg system Compiler system_server
3 3 0 0% S 0K 0K root ksoftirqd/0
1323 1335 0 0% S 676928K 43096K fg u0_a55 Binder_2 com.tencent.mm
51 51 0 0% S 0K 0K root binder
52 52 0 0% S 352K 184K root ueventd /sbin/ueventd
54 54 1 0% S 0K 0K root mtdblock0
55 55 1 0% S 0K 0K root mtdblock1

3. 虚拟内存的查看,目前还看不懂

[ruby] view plaincopy
#cat /proc/vmstat
nr_free_pages 112977
nr_inactive_anon 61
nr_active_anon 36183
nr_inactive_file 39628
nr_active_file 10351
nr_unevictable 0
nr_mlock 0
nr_anon_pages 36180
nr_mapped 15427
nr_file_pages 50046
nr_dirty 0
nr_writeback 0
nr_slab_reclaimable 1455
nr_slab_unreclaimable 2005
nr_page_table_pages 2281
nr_kernel_stack 6
nr_unstable 0
nr_bounce 0
nr_vmscan_write 0
nr_writeback_temp 0
nr_isolated_anon 0
nr_isolated_file 0
nr_shmem 69
nr_dirtied 5665
nr_written 5413
nr_anon_transparent_hugepages 0
nr_dirty_threshold 26869
nr_dirty_background_threshold 6717
pgpgin 197593
pgpgout 255
pswpin 0
pswpout 0
pgalloc_normal 3068
pgalloc_high 61026
pgalloc_movable 0
pgfree 563265
pgactivate 10977
pgdeactivate 0
pgfault 450191
pgmajfault 1011
pgrefill_normal 0
pgrefill_high 0
pgrefill_movable 0
pgsteal_normal 0
pgsteal_high 0
pgsteal_movable 0
pgscan_kswapd_normal 0
pgscan_kswapd_high 0
pgscan_kswapd_movable 0
pgscan_direct_normal 0
pgscan_direct_high 0
pgscan_direct_movable 0
pginodesteal 0
slabs_scanned 0
kswapd_steal 0
kswapd_inodesteal 0
kswapd_low_wmark_hit_quickly 0
kswapd_high_wmark_hit_quickly 0
kswapd_skip_congestion_wait 0
pageoutrun 1
allocstall 0
pgrotated 0
compact_blocks_moved 0
compact_pages_moved 0
compact_pagemigrate_failed 0
compact_stall 0
compact_fail 0
compact_success 0
unevictable_pgs_culled 0
unevictable_pgs_scanned 0
unevictable_pgs_rescued 0
unevictable_pgs_mlocked 0
unevictable_pgs_munlocked 0
unevictable_pgs_cleared 0
unevictable_pgs_stranded 0
unevictable_pgs_mlockfreed 0

4. 虚拟机信息,包括进程的,线程的跟踪信息,这是用来跟踪进程和线程具体点的好地方 。
导出到当前目录 adb pull /data/anr/traces.txt .

二、分析log
1. 查找关键字
通过查找:"null" "error" " "E/","Fatal","NullPointerException","Build fingerprint:","exception","anr","DexOpt"等的错误信息,来定位问题

1)空指针问题
NullPointerException: 这个直接找到java代码,首先分析为什么会是空指针,如果逻辑上没有问题,加上一个判断就可以,也就是说如果为空的时候再次赋值或者直接返回

2).没有捕获异常问题
Exception:
能捕获的话捕获

附上出处链接:http://blog.csdn.net/hugohong/article/details/24325999

如何分析Android的Log 如何分析android的log 如何分析Android的Log Android Log的分布、收集、整理 如何分析Android的Log 如何分析Android的Log 如何读懂和分析Android的logcat以及stack traces 如何分析Android的Log Android Log等级的介绍 Android系统的系统日志有哪几个文件,这些文件中包含什么内容? androidwifilog android log输出 androidlog android抓log androidlog的种类 android中log的用法 android拿log日志 androidctslog android去掉所有log日志
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com