当前位置:   article > 正文

Android笔记(六)(adb使用)_adb查看应用运行内存

adb查看应用运行内存

1. 添加环境变量

此电脑(右击)→ 属性 → 高级系统设置 → 高级 → 环境变量 → 系统变量 → Path(双击)

→新建添加 adb.exe路径

2. adb常用指令

  • adb devices  当前连接了几个设备以及每个连接的状态

  • shell [<shellCommand>]   连接模拟器/设施执行Shell命令,执行完毕后退出远程Shell端l

adb shell pm list packages  列出手机装的所有app的包名 

  • 查看内存
  1. 查看磁盘内存和运行内存:adb shell free
  2. 查看内存详细数据adb shell cat /proc/meminfo
  3. 查看某一个app的内存占用:adb shell dumpsys meminfo <package_name|PID>
  4. 查看单个进程可用的最大内存adb shell getprop dalvik.vm.heapsize //表示不受控情况下的极限堆
  5. 查看单个应用程序的最大内存限制:adb shell getprop dalvik.vm.heapgrowthlimit
  6. 得到的结果为128M,就是说Dalvik Heap size的最大值超过了128M,就很可能发生OOM
  7. 查看设备上进程的cpu和内存占用情况adb shell top
  8. adb shell top >C:\log\sb01.log(将日志输出到本地)
  1. device commands 
  • adb push <local>... <remote> 复制文件/目录到设备
  • adb pull [-a] <remote>... <local> 从设备复制文件/目录
  •   adb sync [ <directory> ]     复制主机内容到设备,仅在改变时(-l 列出但不复制)
  •   adb shell [-e escape] [-n] [-Tt] [-x] [command]

                               运行远程shell命令 (如果没有给出命令,则使用交互式shell)
                                 (-e: choose escape character, or "none"; default '~')
                                 (-n: don't read from stdin)
                                 (-T: disable PTY allocation)
                                 (-t: force PTY allocation)
                                 (-x: disable remote exit codes and stdout/stderr separation)

  •   adb emu <command>  运行模拟器控制台命令
  •   adb logcat [ <filter-spec> ]   查看设备日志
  •   adb forward --list       列出所有远程socket连接

                                 the format is a list of lines with the following format:
                                    <serial> " " <local> " " <remote> "\n"

  •   adb forward <local> <remote> - forward socket connections

                                 forward specs are one of:
                                   tcp:<port>
                                   localabstract:<unix domain socket name>
                                   localreserved:<unix domain socket name>
                                   localfilesystem:<unix domain socket name>
                                   dev:<character device name>
                                   jdwp:<process pid> (remote only)

  •   adb forward --no-rebind <local> <remote>

                               - same as 'adb forward <local> <remote>' but fails
                                 if <local> is already forwarded

  •   adb forward --remove <local> - remove a specific forward socket connection
  •   adb forward --remove-all     - remove all forward socket connections
  •   adb reverse --list           - list all reverse socket connections from device
  •   adb reverse <remote> <local> - reverse socket connections

                                 reverse specs are one of:
                                   tcp:<port>
                                   localabstract:<unix domain socket name>
                                   localreserved:<unix domain socket name>
                                   localfilesystem:<unix domain socket name>

  •   adb reverse --no-rebind <remote> <local>

                               - same as 'adb reverse <remote> <local>' but fails
                                 if <remote> is already reversed.

  •   adb reverse --remove <remote>

                               - remove a specific reversed socket connection

  •   adb reverse --remove-all     - remove all reversed socket connections from device
  •   adb jdwp                     - list PIDs of processes hosting a JDWP transport
  •   adb install [-lrtsdg] <file>

                               把安装包发送到设备并安装
                                 (-l: “L”意味着锁的应用程序)
                                 (-r: “R”意味着重新安装应用程序,保持其数据)
                                 (-t: allow test packages)
                                 (-s: “S”是指安装在SD卡代替内部存储)
                                 (-d: allow version code downgrade (debuggable packages only))
                                 (-g: grant all runtime permissions)

  •   adb install-multiple [-lrtsdpg] <file...>

                               - push this package file to the device and install it
                                 (-l: forward lock application)
                                 (-r: replace existing application)
                                 (-t: allow test packages)
                                 (-s: install application on sdcard)
                                 (-d: allow version code downgrade (debuggable packages only))
                                 (-p: partial application install)
                                 (-g: grant all runtime permissions)

  •   adb uninstall [-k] <package>   卸载应用程序

                                 (“K”意味着保持数据和缓存目录)

  •   adb bugreport [<path>]   返回设备上的一个bug报告的所有信息    

                                 If <path> is a file, the bug report will be saved as that file.
                                 If <path> is a directory, the bug report will be saved in that directory with the name provided by th
e device.
                                 If <path> is omitted, the bug report will be saved in the current directory with the name provided by
 the device.
                                 NOTE: if the device does not support zipped bug reports, the bug report will be output on stdout.
  adb backup [-f <file>] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] [<packages...>]
                               - write an archive of the device's data to <file>.
                                 If no -f option is supplied then the data is written
                                 to "backup.ab" in the current directory.
                                 (-apk|-noapk enable/disable backup of the .apks themselves
                                    in the archive; the default is noapk.)
                                 (-obb|-noobb enable/disable backup of any installed apk expansion
                                    (aka .obb) files associated with each application; the default
                                    is noobb.)
                                 (-shared|-noshared enable/disable backup of the device's
                                    shared storage / SD card contents; the default is noshared.)
                                 (-all means to back up all installed applications)
                                 (-system|-nosystem toggles whether -all automatically includes
                                    system applications; the default is to include system apps)
                                 (<packages...> is the list of applications to be backed up.  If
                                    the -all or -shared flags are passed, then the package
                                    list is optional.  Applications explicitly given on the
                                    command line will be included even if -nosystem would
                                    ordinarily cause them to be omitted.)

  •   adb restore <file>           - restore device contents from the <file> backup archive
  •   adb disable-verity           - disable dm-verity checking on USERDEBUG builds
  •   adb enable-verity            - re-enable dm-verity checking on USERDEBUG builds
  •   adb keygen <file>            - generate adb public/private key. The private key is stored in <file>,

                                 and the public key is stored in <file>.pub. Any existing files
                                 are overwritten.

  •   adb help                     - show this help message
  •   adb version                  - show version num
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/805211
推荐阅读
相关标签
  

闽ICP备14008679号