Android Performance Optimization Basics ---

The process address space from 0 to 4GB, diagram is as follows:
Android Performance Optimization Basics ---

Stack space (push and pop) controlled by the operating system, wherein the main storage address of a function, the function parameters, local variables, etc., it does not require large space Stack, generally a few MB in size.
Heap space is controlled by using the programmer, the programmer can use the function call malloc, new, free, delete operation like this address space. Heap for the program to complete the complex task of providing memory space, so the space is relatively large, typically a few hundred MB to several GB.
Android the process:
(. 1) native process: using C / C ++ implementation, the process does not comprise linux dalvik example, the / system / bin / directory operation program files are present in the native form of the process. / system / bin / surfaceflinger, / system / bin / rild, procrank so is the native process.
(2) java process: dalvik instantiated virtual machine instance linux process, the main function entry process is a function of java. dalvik virtual machine instance is hosting process linux process fork () system call to create, so the java process on each of the android is actually a linux process, but the process one more dalvik virtual machine instance. Therefore, memory allocation process is more complex than native java process. 3, Android application system are basically java process, such as Launcher, InCallUI, Contact, SystemUI like.

Java process structure:
Android Performance Optimization Basics ---

VSS- Virtual Set Size 虚拟耗用内存(包含共享库占用的内存)
RSS- Resident Set Size 实际使用物理内存(包含共享库占用的内存)
PSS- Proportional Set Size 实际使用的物理内存(比例分配共享库占用的内存)
USS- Unique Set Size 进程独自占用的物理内存(不包含共享库占用的内存)
一般来说内存占用大小有如下规律:VSS >= RSS >= PSS >= USS
注意:dumpsys meminfo可以查看native进程和java进程,而procrank只能查看java进程。
PSS(Proportional Set Size),表示进程实际使用的物理内存,是由私有内存加上按比例分担计算的各进程共享内存得到的值。例如,如果有三个进程都使用了一个消耗30K内存的so库,那么每个进程在计算这部分PSS值的时候,只会计算10K。总的计算公式是:
Dalvik PSS内存 = 私有内存Private Dirty + (共享内存Shared Dirty / 共享的进程数)
从实际含义来讲,Private Dirty部分存放的是应用new出来的对象实例,是每个应用所独有的,不会再共享。Shared Dirty部分主要是zygote加载的Android框架部分,会被所有Android应用进程共享。通常进程数的值在10-50的范围内。
PSS是一个非常有用的数值,如果系统中所有的进程的PSS相加,所得和即为系统占用内存的总和。但要注意的是,进程的PSS并不代表进程结束后系统能够回收的内存大小。
1、 Native Heap
mallinfo是一个C库, mallinfo函数提供了各种各样的通过C的malloc()函数分配的内存的统计信息。
Naitve Heap Size: 从mallinfo usmblks获得,代表最大总共分配空间
Native Heap Alloc: 从mallinfo uorblks获得,总共分配空间
Native Heap Free: 从mallinfo fordblks获得,代表总共剩余空间
Native Heap Size 约等于Native Heap Alloc + Native Heap Free
native heap的增长并不受dalvik vm heapsize的限制。只要RAM有剩余空间,可以一直在native heap上申请空间。

2、 Dalvik Heap
和Java Heap概念相同,指java代码申请的内存。统计/dev/ashmem/dalvik-heap和/dev/ashmem/dalvik-zygote占用内存。

3、 Dalvik Other
其它以/dev/ashmem/dalvik-开头的内存区域归为Dalvik Other。

4、 Stack
由操作系统控制,其中主要存储函数地址、函数参数、局部变量等等,所以Stack空间不需要很大,一般为几MB大小。

5、 Ashmem
Ashmem对应所有/dev/ashmem/下不以dalvik-开头的内存区域

6、 Other dev
Other dev对应的是以/dev下其他的内存区域。

7, mmap
mmap file in a known classification of several extensions, the rest classified as other mmap. Divided .so mmap, .apk mmap, .ttf mmap , .dex mmap, .oat mmap, .art mmap, other mmap. Dex application will occupy a large space, and with the increase of the code so that large files dex, amount of memory will increase. Reduced dex (corresponding to reduce code) is possible to reduce the size of this memory footprint, while also reducing memory dalvik portion.

. 8, mtrack GL
GL GL Reported mtrack IS-Driver Memory Usage. It apos SUM of the Primarily The sizes Texture GL, GL Command buffers, the RAM Fixed Global Driver overheads, etc.
GL GL mtrack a driver reports memory usage. Mainly GL texture size, GL command buffer, the sum of the fixed global overhead RAM drive or the like.
9, Unknown
Unknown

Memory analysis tool -showmap
1 | Mangosteen root @: / # PS | grep videomeeting
u0_a60 7853 1708 1924376 134 956 SyS epoll 7fa364781c S com.xxxxxx.xxxx.videomeeting
root @ Mangosteen: / # showmap -a 7853

Show a lot of content, the following list only occupy a larger PSS items:
Android Performance Optimization Basics ---

Guess you like

Origin blog.51cto.com/14348552/2403181