- 浏览: 1504703 次
- 性别:
- 来自: 南京
文章分类
- 全部博客 (419)
- XMPP (19)
- Android (180)
- Java (59)
- Network (4)
- HTML5 (13)
- Eclipse (9)
- SCM (23)
- C/C++ (4)
- UML (4)
- Libjingle (15)
- Tools&Softwares (29)
- Linphone (5)
- Linux&UNIX (6)
- Windows (18)
- Google (10)
- MISC (3)
- SIP (6)
- SQLite (5)
- Security (4)
- Opensource (29)
- Online (2)
- 文章 (3)
- MemoryLeak (10)
- Decompile (5)
- Ruby (1)
- Image (1)
- Bat (4)
- TTS&ASR (28)
- Multimedia (1)
- iOS (20)
- Asciiflow - ASCII Flow Diagram Tool.htm (1)
- Networking (1)
- DLNA&UPnP (2)
- Chrome (2)
- CI (1)
- SmartHome (0)
- CloudComputing (1)
- NodeJS (3)
- MachineLearning (2)
最新评论
-
bzhao:
点赞123!
Windows的adb shell中使用vi不乱码方法及AdbPutty -
wahahachuang8:
我觉得这种东西自己开发太麻烦了,就别自己捣鼓了,找个第三方,方 ...
HTML5 WebSocket 技术介绍 -
obehavior:
view.setOnTouchListenerview是什么
[转]android 一直在最前面的浮动窗口效果 -
wutenghua:
[转]android 一直在最前面的浮动窗口效果 -
zee3.lin:
Sorry~~
When I build "call ...
Step by Step about How to Build libjingle 0.4
http://elinux.org/Using_smem_on_Android
Using smem on Android
smem is a handy tool for analyzing system memory.
Quick steps
For the impatient, here are some quick steps:
* download smem * hg clone http://selenic.com/repo/smem * cd smem * (install python-matplotlib and python-matplotlib-tk, if needed) * cross-compile smemcap for Android, using something like 'agcc' * agcc smemcap.c -o android-smemcap * install android-smemcap onto your target * adb shell mkdir /data/smem * adb push android-smemcap /data/smem * collect memory information on target * adb shell "/data/smem/android-smemcap >/data/smem/memdata1.tar" * retreive the collected data * adb pull /data/smem/memdata1.tar . * review the data on host * smem -S memdata1.tar
This document describes how to use 'smem' with Android.
Introduction
smem is a memory tool for analyzing the amount of memory usage on a Linux system. The 'ps' tool provided with Android only shows the VSIZE and RSS memory columns. Even if you install busybox on an android system, that tool's 'ps' will also only show you only the VSIZE value. VSIZE is the total size of the virtual image, and RSS is the resident set size - the amount of physical pages accounted by the kernel to a particular process. These numbers are not very useful to indicate the actual cost in memory of a particular application or daemon.
On the smem web site it says:
smem is a tool that can give numerous reports on memory usage on Linux systems. Unlike existing tools, smem can report proportional set size (PSS), which is a more meaningful representation of the amount of memory used by libraries and applications in a virtual memory system.
Because large portions of physical memory are typically shared among multiple applications, the standard measure of memory usage known as resident set size (RSS) will significantly overestimate memory usage. PSS instead measures each application's "fair share" of each shared area to give a realistic measure. of the activity of a system during boot.
smem consists of a data capture tool, for use on an android target, and an analysis tool for use on a development host machine.
Overview of Steps to Use smem
To use smem on an Android System, you need to perform the following steps:
* install the smem tool on your host machine * build smemcap on your host machine (or use a pre-built binary) * install smemcap on your Android target system * use smemcap to capture the memory information from /proc on the target * retrieve the collected data from the system * use the smem tool with the collected data, on the host * view memory information and charts * [optionally] provide additional system information
These steps will be described in detail in the following sections. This paper was written based on Android 1.5 software and SDK.
Detailed Instructions
Installing the smem tool
smem can be downloaded from http://selenic.com/repo/smem
Download using the mercurial tool (hg)
$ hg clone http://selenic.com/repo/smem destination directory: smem requesting all changes adding changesets adding manifests adding file changes added 37 changesets with 40 changes to 5 files 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
This will create a directory called 'smem' in the current directory.
Usually, you will want to place the 'smem' program on your path. This can be done by copying smem to /usr/local/bin, like so (as root):
$ cp smem/smem /usr/local/bin
smem has a few requirements:
- a reasonably modern kernel (> 2.6.27 or so)
- a reasonably recent version of Python (2.4 or so)
The smem tool can be used in text mode with no further installation.
However, smem also provides the ability to produce nice charts and graphs. For this, it needs the python matplotlib plotting library.
On Fedora, you can install this with the command:
$ yum install python-matplotlib python-matplotlib-tk
Other Linux distributions may also have packages for matplotlib.
Here are links to information if you need to directly download and/or install matplotlib
- http://matplotlib.sourceforge.net/index.html - home page
- http://sourceforge.net/projects/matplotlib - download area
- http://matplotlib.sourceforge.net/users/installing.html - install instructions
Building 'smemcap' (or use pre-built binary)
To collect the memory information from the /proc filesystem on the target you need to run the 'smemcap' program. smem also includes a shell script called 'capture' which can collect the data on a standard Linux desktop. However, the Android environment does not have the necessary shell environment or command line tools for this program to work. So you will need to use the compiled C program.
Compile the smemcap program as a native Android program against the bionic C library. Details about this are outside the scope of this document, but you can use the instructions here: Compiling Native Apps for Android
If you have installed 'agcc', then the following steps should work:
$ cd smem $ agcc smemcap.c -o android-smemcap
Pre-built binary (for G1)
Alternatively, you can use a pre-built capture program . This one worked on my Android G1 phone and on an OMAP EVM board.
Note: Due to constraints on file uploads on this wiki, I had to upload it as a tar file. Download it and untar with: 'tar -xvf Android-smemcap.tar'
Installing 'android-smemcap' onto your Android target
To install the android-smemcap program on your target, you just need to copy the program, and make sure it is executable. It is recommended to make a separate directory for smem capture data, on the /data portion of the target file system. (However, any writable directory can be used, such as one on an sdcard.)
Make the smem directory, copy the file:
$ adb shell mkdir /data/smem $ adb push android-smemcap /data/smem
You should check that the program is executable:
$ adb shell chmod 777 /data/smem/android-smemcap $ adb shell ls -l /data/smem -rwxrwxrwx root root 7391 2009-06-24 14:47 android-smemcap
Collect memory information on the target
Now, to measure the memory usage on the target, use the android-smemcap program to collect the data from the /proc filesystem.
$ adb shell $ cd /data/smem $ ./android-smemcap >memdata1.tar $ exit
You can also do this directly from the host, using the adb shell:
$ adb shell "/data/smem/android-smemcap >/data/smem/memdata1.tar"
Note the use of quotes to have the shell redirection on the target stay on the target. Due to the binary nature of the data output by android-smemcap, you can not redirect it directly through the 'adb shell' command to the host filesystem.
Retrieving the collected data from the system
Now, collect the data from the target, and retrieve it to the host:
$ adb pull /data/smem/memdata1.tar .
This will pull the just-created file 'memdata1.tar' from the target and place it in the current directory.
Review the data on the host
Now, you can use the smem tool on the host, to view the target process data:
$ smem -S memdata1.tar PID User Command Swap USS PSS RSS 32 0 /system/bin/debuggerd 0 64 70 252 30 1000 /system/bin/servicemanager 0 80 86 264 36 1002 /system/bin/dbus-daemon --s 0 92 106 368 39 0 /system/bin/sh /runme.sh 0 72 106 316 37 0 /system/bin/installd 0 100 108 332 2462 0 /system/bin/sh - 0 84 118 332 31 0 /system/bin/vold 0 136 144 392 41 0 /sbin/adbd 0 144 144 156 1 0 /init 0 152 154 172 3780 0 ./android-smemcap 0 188 195 384 40 1008 /system/bin/akmd 0 268 303 688 33 0 /system/bin/rild 0 444 504 984 35 1013 /system/bin/mediaserver 0 876 1458 2948 181 0 com.android.voicedialer 0 948 1550 10668 263 0 com.instamapper.gpstracker 0 1072 1633 10992 252 0 com.rerware.android.MyBacku 0 1080 1665 11348 289 0 com.android.music 0 1204 1892 11436 271 0 com.biggu.shopsavvy 0 1236 2050 12344 241 0 com.android.alarmclock 0 1488 2087 12264 215 0 com.android.email 0 1524 2164 12116 302 0 com.google.android.gm 0 1508 2170 11928 280 0 com.acme.android.powermanag 0 1884 2533 12688 135 0 com.android.mms 0 2036 2711 12708 164 0 android.process.media 0 2208 2840 13076 412 0 com.biggu.shopsavvy:remote 0 2036 2904 13668 228 0 com.android.calendar 0 2296 3005 13596 34 0 zygote /bin/app_process -Xz 0 1088 3218 16688 202 0 com.google.android.apps.map 0 2472 3334 14324 106 0 com.android.phone 0 4928 5891 16664 155 0 com.google.process.gapps 0 4628 5933 17408 108 0 android.process.acore 0 7288 9023 29560 66 0 system_server 0 10188 12636 35056
Viewing information and charts
There are a number of interesting options that smem provides, for filtering, analyzing and visualizing the process data.
Here are some interesting options:
Map PIDs AVGPSS PSS /system/lib/hw/copybit.msm7k.so 1 8 8 /system/lib/hw/lights.msm7k.so 1 8 8 /system/lib/hw/sensors.trout.so 1 12 12 /system/lib/libagl.so 1 48 48 /system/lib/libandroid_servers.so 1 16 16 /system/lib/libhtc_acoustic.so 1 4 4 /system/lib/libhtc_ril.so 1 168 168 /system/lib/libril.so 1 28 28 /system/lib/libsoundpool.so 1 4 4 /system/lib/libsurfaceflinger.so 1 108 108 /system/lib/libsystem_server.so 1 8 8 /system/lib/liba2dp.so 2 6 12 /system/lib/libaudio.so 2 14 28 /system/lib/libaudioflinger.so 2 62 124 /system/lib/libcamera.so 2 14 28 /system/lib/libcameraservice.so 2 20 40 /system/lib/libmediaplayerservice.so 2 52 104 /system/lib/libmedia_jni.so 19 1 35 /system/lib/libwebcore.so 19 10 191 /system/lib/libEGL.so 20 0 15 /system/lib/libGLESv1_CM.so 20 0 12 /system/lib/libOmxCore.so 20 0 4 /system/lib/libaes.so 20 0 4 /system/lib/libandroid_runtime.so 20 13 267 /system/lib/libbluedroid.so 20 0 8 /system/lib/libcorecg.so 20 2 52 /system/lib/libcrypto.so 20 21 424 /system/lib/libdrm1.so 20 0 7 /system/lib/libdvm.so 20 18 375 /system/lib/libemoji.so 20 0 4 /system/lib/libhardware.so 20 0 7 /system/lib/libicudata.so 20 13 260 /system/lib/libicui18n.so 20 15 304 /system/lib/libicuuc.so 20 18 363 /system/lib/libmedia.so 20 5 102 /system/lib/libnativehelper.so 20 6 135 /system/lib/libopencoreauthor.so 20 13 265 /system/lib/libopencorecommon.so 20 9 185 /system/lib/libopencoreplayer.so 20 29 593 /system/lib/libpixelflinger.so 20 3 71 /system/lib/libsgl.so 20 29 583 /system/lib/libskiagl.so 20 0 4 /system/lib/libsonivox.so 20 0 7 /system/lib/libsqlite.so 20 16 325 /system/lib/libssl.so 20 4 97 /system/lib/libui.so 20 12 245 /system/lib/libvorbisidec.so 20 4 94 /system/lib/libdbus.so 21 0 16 /system/lib/libexpat.so 21 3 67 /system/lib/libgps.so 21 2 52 /system/lib/libhardware_legacy.so 21 1 40 /system/lib/libnetutils.so 21 0 16 /system/lib/librpc.so 21 0 16 /system/lib/libwpa_client.so 21 0 12 /system/lib/libutils.so 22 18 404 /system/lib/libz.so 22 3 77 /system/lib/libcutils.so 24 5 131 /system/lib/liblog.so 25 0 24 /system/lib/libstdc++.so 29 1 40 /system/lib/libc.so 30 14 444 /system/lib/libm.so 30 2 88
PID User Command Swap USS PSS RSS 135 0 com.android.mms 0 8 16 264 164 0 android.process.media 0 8 16 264 181 0 com.android.voicedialer 0 8 16 260 202 0 com.google.android.apps.map 0 8 16 264 215 0 com.android.email 0 8 16 260 228 0 com.android.calendar 0 8 16 264 241 0 com.android.alarmclock 0 8 16 264 252 0 com.rerware.android.MyBacku 0 8 16 260 263 0 com.instamapper.gpstracker 0 8 16 260 271 0 com.biggu.shopsavvy 0 8 16 260 280 0 com.acme.android.powermanag 0 8 16 260 289 0 com.android.music 0 8 16 260 302 0 com.google.android.gm 0 8 16 264 412 0 com.biggu.shopsavvy:remote 0 8 16 264 30 1000 /system/bin/servicemanager 0 16 19 124 32 0 /system/bin/debuggerd 0 16 19 132 39 0 /system/bin/sh /runme.sh 0 16 19 132 2462 0 /system/bin/sh - 0 16 19 136 36 1002 /system/bin/dbus-daemon --s 0 16 20 148 3780 0 ./android-smemcap 0 16 20 144 31 0 /system/bin/vold 0 20 25 192 37 0 /system/bin/installd 0 20 25 168 40 1008 /system/bin/akmd 0 20 25 176 106 0 com.android.phone 0 12 25 276 33 0 /system/bin/rild 0 20 30 204 108 0 android.process.acore 0 16 36 312 34 0 zygote /bin/app_process -Xz 0 8 83 472 35 1013 /system/bin/mediaserver 0 44 95 344 155 0 com.google.process.gapps 0 28 187 612 66 0 system_server 0 32 248 772
Sample Charts
Here are some examples of graphical charts produced by smem
Providing additional system information
You can provide additional information to smem (such as the kernel image size), using the -R and -K options:
Here is an example showing the 'whole system' memory information, while specifing a kernel vmlinux image:
$ smem -S ftrace-kernel.tar -w -t -K /home/tbird/work/android/kernel-msm/build/g1/vmlinux Area Used Cache Noncache firmware/hardware 0 0 0 kernel image 4515 0 4515 kernel dynamic memory 17500 4784 12716 userspace memory 78544 28736 49808 free memory 1988 1988 0 ---------------------------------------------------------- 102547 35508 67039
In this example, my kernel was a test kernel that was significantly larger than a standard production kernel.
Using the graphical viewer
The graphical viewer provides options for zooming and panning portions of the graph, for adjusting graph display parameters, switching between views, and saving a view to an image file.
Here is a snapshot of the smem (matplotlib) chart viewer:
Here are some tips:
Sometimes it is difficult to read the chart labels. You can view the labels more easily if you pan and zoom the chart.
To zoom in on an area, click on the 'zoom to rectangle' button. Drag a rectangle in the viewing area. For a bar chart, the rectangle must reside within the graph area of the chart (above the x axis and to the right of the y axis). Once you unclick your mouse button, a zoomed image is then shown. You can pan the zoomed image by clicking the 'pan axes' button, and dragging the image with the left mouse button. (This "pan axes" button puts the chart in 'pan/zoom' mode. Click the button again to revert to regular view mode.)
You can also zoom using the right mouse button in the 'pan/zoom' mode.
You can adjust the location of the chart on the page (which is also sometimes necessary to see the full labels), by clicking on the "configure subplots" button. Experiment with changing different parameters, such as the bottom or left parameters.
Save a view to a file using the "save the figure" button. Select the image format to save in, from the drop-down list at the bottom of the dialog. Available formats are: bmp, eps, jpg, png, ps, svg.
Interpreting the results
See the smem web site for an explanation of USS and PSS, and how these measurements should be interpreted to analyze a running system.
发表评论
-
JAAS authentication in Tomcat example
2018-11-19 20:32 630... -
druid 数据库密码加密
2015-03-12 17:43 1394cmd命令:1、切换的druid-0.2.9.jar包所在目 ... -
[Android] 为Android安装BusyBox —— 完整的bash shell
2013-12-27 10:19 1490http://www.cnblogs.com/xiaowen ... -
Windows的adb shell中使用vi不乱码方法及AdbPutty
2013-12-27 10:17 7576http://www.veryhuo.com/down/ht ... -
AppMobi推出新XDK,可创建测试PhoneGap项目
2012-09-03 13:39 2637AppMobi今天发布了一个新的工具PhoneGap Mobi ... -
Sencha
2012-09-03 12:59 1185http://www.sencha.com/ Se ... -
jQuery Mobile学习
2012-09-01 12:33 1691使用Jquery Mobile设计Android通讯录 ... -
BackBone
2012-09-01 12:34 1260Backbone.js 是一种重量级javascript M ... -
jQTouch
2012-08-30 15:57 984A Zepto/jQuery plugin for mobil ... -
SwiFTP
2012-08-30 15:43 1307SwiFTP is a FTP server that run ... -
kWS
2012-08-30 15:41 1198kWS is a lightweight and fast W ... -
jQuery Mobile
2012-08-30 15:07 1027http://jquerymobile.com/ -
PhoneGap
2012-08-30 15:07 1044http://phonegap.com/ -
Android Button background image pressed/highlighted and disabled states without
2012-08-06 12:49 1678http://shikii.net/blog/android- ... -
[AndriodTips]Image, saved to sdcard, doesn't appear in Android's Gallery app
2012-08-04 16:15 1158http://stackoverflow.com/questi ... -
Voice detection for Android
2012-07-23 11:39 2347Here it is, my fist JAVA applic ... -
[AndroidTip]local reference table overflow (max=512)的错误解决
2012-07-22 22:56 6049JNI层coding经常会遇到ReferenceTable o ... -
[AndroidTip]EditText如何初始状态不获得焦点?
2012-07-22 15:35 1226最简单的办法是在EditText前面放置一个看不到的Linea ... -
[AndroidTip]android textview滚动条
2012-07-21 14:29 1298本来是想做一个显示文字信息的,当文字很多时View的高度不能超 ... -
Google公布Android 4.1完整功能
2012-07-16 09:48 3185http://www.android.com/about/je ...
相关推荐
在Android系统中,`smem`是一个非常有用的工具,它用于查看系统内存的状态,包括物理内存和内核内存。这个工具对于系统开发者、调试人员以及性能优化专家来说是必不可少的,因为它提供了对内存分配和使用情况的深入...
smem是一款命令行下的内存使用情况报告工具,他能够给用户提供Linux系统下的内存使用的多种报告,seme与现有工具不同的是,可以报告PSS情况(实际使用的物理内存(PSS),从而可以衡量虚拟内存系统库和应用程序所占用的内存...
在Android系统中,内存分配是一个复杂且关键的过程,它直接影响着设备的性能和稳定性。本文主要探讨了Android手机内存的分配结构,以及如何查看和理解这些分配情况。 首先,我们需要了解Android内存的基本划分。...
SMEM_Fully_Pipelined_Design SMEM ++,用于基因组测序的全流水线和时间多路复用SMEM播种加速器 此发布的代码是SMEM FPGA内核代码,其详细信息在我们的论文中进行了描述。 最初的实现是在harp2上的,并且存在版权...
标题中的"arch_arm_mach-msm_smem_log_qualcommmsm7200_exploredr1_linux...此外,这也可以作为学习Qualcomm MSM平台特性的实例,对于从事Android或其他基于Linux系统的移动设备开发的工程师来说,具有很高的实践价值。
smem-map是一款强大的开源工具,专门用于分析进程的虚拟内存空间,帮助用户识别那些内存区域的内容保持静态不变。这个工具对于系统管理员、开发者以及性能优化专家来说尤其有用,因为它能够提供深入的内存使用情况...
### Android多媒体编程从初学到精通:多核通信详解 #### 一、引言 随着智能终端技术的迅速发展,特别是2010年末以来,高端智能终端和移动设备的CPU性能大幅提升,例如采用Cortex-A8双核处理器的高端手机以及采用...
reports physical memory usage, taking shared memory pages into account. Unshared memory is reported as the USS (Unique Set Size). Shared memory is divided evenly among the processes sharing that ...
smem的安装可以在Debian、Ubuntu或Linux Mint上使用apt-get install smem命令,在Fedora或CentOS/RHEL上使用yum install smem python-matplotlib命令进行安装。 使用smem可以检查内存使用情况,例如可以使用smem...
3. 符号位不扩展的加法:ADDS指令用于不扩展符号位的加法,`ADDS Smem, src`将Smem中的无符号值与累加器中的值相加,保留符号位不变。 二、减法指令 1. 基本减法:SUB指令从累加器中减去源操作数,例如`SUB Smem, ...
快照多光谱内窥镜检查(SMEM) 该存储库包含穆乔,马佳伟,于振明,徐坤等人撰写的论文《快照多光谱内窥镜检查(光学信函,2020年)》的代码。 、、、 概述者 此源代码提供了端到端DNN,用于重建快照压缩成像器捕获...
- 具体操作为:先在Trace32中运行`dotools\debug\smemlog.cmm`,然后运行`perl smem_log.pl > smemlog.txt`来获取SMEM Log。 2. **使用ADB工具**: - 对于没有Trace32工具的用户,可以通过ADB来实现SMEM Log的...
在IT领域,尤其是在Android开发和系统优化中,内存管理是一个至关重要的部分。本文将深入探讨如何使用shell命令在Linux环境中捕获和分析内存状态,主要关注两种不同的内存快照格式:native内存和HProf文件。 首先,...
AIX提供了一套工具集,如vmstat、smem和kmem,用于监控系统的内存使用趋势。通过定期收集这些工具的输出,分析内存的增减变化,可以识别出是否存在整体上的内存泄漏现象。 4. 定位具有内存泄漏的单个进程: 结合...
f3 log 记录了高通平台上的错误信息,而 smem log 记录了高通平台上的内存信息。获取 f3 log 和 smem log 可以按照以下步骤进行: 1. 准备高通平台上的 dump 信息 2. 使用 dump 信息获取 f3 log 和 smem log 获取 ...
- **ADD Smem[, SHIFT], src[, dst]**:允许用户指定移位量,将Smem左移指定位数后再与src中的值相加。 - **ADDXmem, SHFT, src**:与上一条类似,但是操作数取自Xmem。 - **ADDXmem, Ymem, dst**:两个操作数Xmem和...
ADD指令的格式为:ADD Smem, src, 其中Smem是源操作数,src是目的寄存器。例如: ```assembly ADD @x2, A ``` 这条指令将x2的值加到累加器A中。 减法运算 在这个实验中,我们使用SUB指令来实现减法运算。SUB指令...
smem log是Qualcomm平台上的一个重要LOG,记录了系统的内存使用情况。使用trace32工具可以 dump 出smem log。trace32是一个强大的调试工具,包括了许多 debug 功能。 首先,需要在 Trace32 中运行以下命令: `Run ...
- **smem0x53000000 0x00000000 32**:这行配置指定了一个起始于0x53000000地址处的内存区域,其初始值为0x00000000,表示该内存区域在初始化时被清零。 - **smem0x4a000008 0xFFFFFFFF 32**:这个配置项表明位于0x...
2. **smem_alloc, smem_get_entry, smem_find**:这些函数允许MODEM在Share Memory中分配和查找结构化数据,AP则可以在合适的时间进行读取。通常,MODEM负责写入数据,而AP负责读取,反向操作并不建议。 3. **SMD ...