dumpsys meminfo 含義

簡單的查看內(nèi)存信息可以使用命令:adb shell dumpsys meminfo

其入口:

android/frameworks/native/cmds/dumpsys/main.cpp

int main(int argc, char* const argv[]) {
    signal(SIGPIPE, SIG_IGN);
    sp<IServiceManager> sm = defaultServiceManager();
    fflush(stdout);
    if (sm == nullptr) {
        ALOGE("Unable to get default service manager!");
        aerr << "dumpsys: Unable to get default service manager!" << endl;
        return 20;
    }

    Dumpsys dumpsys(sm.get());
    return dumpsys.main(argc, argv);
}

通過解析參數(shù),會(huì)調(diào)用對(duì)應(yīng)servicemanager中注冊(cè)的服務(wù)meminfo 的dump接口

android/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java

public void setSystemProcess() {
    ServiceManager.addService("meminfo", new MemBinder(this));
}

所以執(zhí)行adb shell dumpsys meminfo 后最終會(huì)調(diào)用ActivityManagerService如下dump接口:

    static class MemBinder extends Binder {
        ActivityManagerService mActivityManagerService;
        MemBinder(ActivityManagerService activityManagerService) {
            mActivityManagerService = activityManagerService;
        }

        @Override
        protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
            if (!DumpUtils.checkDumpAndUsageStatsPermission(mActivityManagerService.mContext,
                    "meminfo", pw)) return;
            mActivityManagerService.dumpApplicationMemoryUsage(fd, pw, "  ", args, false, null);
        }
    }

dump出的信息類似以下(有精簡)

Applications Memory Usage (in Kilobytes):
Uptime: 14442 Realtime: 14442

Total PSS by process:
     87,694K: system (pid 1648)
     62,996K: com.android.systemui (pid 1786)
     58,326K: com.google.android.apps.nexuslauncher (pid 2297 / activities)
     47,529K: com.google.android.googlequicksearchbox:search (pid 2367)
     46,386K: com.google.android.apps.maps (pid 2655)
     38,446K: com.google.android.inputmethod.latin (pid 1771)
     36,308K: com.google.android.gms.persistent (pid 2222)
     22,993K: com.android.phone (pid 1897)
     22,085K: zygote (pid 1521)
     21,734K: com.google.android.gms (pid 2594)
     21,199K: com.google.android.apps.photos (pid 2878)
     15,911K: com.google.android.apps.messaging:rcs (pid 2849)
     14,825K: com.google.android.apps.messaging (pid 2786)
     11,901K: com.google.android.dialer (pid 2134)
     11,842K: com.android.settings (pid 1928)
     11,403K: android.process.acore (pid 2449)
     11,009K: webview_zygote32 (pid 1818)
     ......
Total PSS by OOM adjustment:
    181,467K: Native
         22,085K: zygote (pid 1521)
         21,199K: com.google.android.apps.photos (pid 2878)
         15,911K: com.google.android.apps.messaging:rcs (pid 2849)
         11,009K: webview_zygote32 (pid 1818)
          7,350K: media.codec (pid 1534)
          6,036K: zygote (pid 2927)
          5,862K: audioserver (pid 1522)
          5,359K: rild (pid 1535)
          5,236K: wpa_supplicant (pid 1893)
          5,135K: mediaserver (pid 1530)
          4,379K: surfaceflinger (pid 1439)
          ......
     87,694K: System
         87,694K: system (pid 1648)
     85,989K: Persistent
         62,996K: com.android.systemui (pid 1786)
         22,993K: com.android.phone (pid 1897)
    142,163K: Foreground
         58,326K: com.google.android.apps.nexuslauncher (pid 2297 / activities)
         47,529K: com.google.android.googlequicksearchbox:search (pid 2367)
         36,308K: com.google.android.gms.persistent (pid 2222)
     20,794K: Visible
         10,085K: com.google.android.googlequicksearchbox:interactor (pid 2240)
          6,223K: com.google.process.gservices (pid 2324)
          4,486K: com.android.printspooler (pid 2398)
     38,446K: Perceptible
         38,446K: com.google.android.inputmethod.latin (pid 1771)
     53,109K: Previous
         21,734K: com.google.android.gms (pid 2594)
         11,403K: android.process.acore (pid 2449)
          9,451K: android.process.media (pid 2217)
          5,795K: com.google.process.gapps (pid 2507)
          4,726K: com.google.android.partnersetup (pid 2533)
    118,227K: Cached
         46,386K: com.google.android.apps.maps (pid 2655)
         14,825K: com.google.android.apps.messaging (pid 2786)
         11,901K: com.google.android.dialer (pid 2134)
         11,842K: com.android.settings (pid 1928)
          8,478K: com.google.android.deskclock (pid 2057)
          6,047K: com.android.contacts (pid 2551)
          5,523K: com.android.cellbroadcastreceiver (pid 2112)
          5,187K: com.android.providers.calendar (pid 2616)
          4,208K: com.android.managedprovisioning (pid 2579)
          3,830K: com.android.keychain (pid 2427)

Total PSS by category:
    204,398K: .dex mmap
    109,618K: .so mmap
    105,009K: Native
     85,917K: .apk mmap
     57,481K: Dalvik
     39,615K: .oat mmap
     32,382K: .art mmap
     24,693K: Dalvik Other
     21,536K: Unknown
     19,962K: Other mmap
     14,090K: .ttf mmap
     11,148K: Stack
      1,378K: Other dev
        516K: Ashmem
        140K: .jar mmap
          6K: Cursor
          0K: Gfx dev
          0K: EGL mtrack
          0K: GL mtrack
          0K: Other mtrack

Total RAM: 1,530,604K (status normal)
 Free RAM:   775,291K (  118,227K cached pss +   139,608K cached kernel +   517,456K free)
 Used RAM:   690,302K (  609,662K used pss +    80,640K kernel)
 Lost RAM:    65,011K
   Tuning: 192 (large 192), oom   184,320K, restore limit    61,440K (high-end-gfx)

Uptime: 表示啟動(dòng)到現(xiàn)在的時(shí)長,不包含休眠的時(shí)間凳宙,單位毫秒(ms)
Realtime: 表示啟動(dòng)到現(xiàn)在的時(shí)長兴猩,包含休眠的時(shí)間,單位毫秒(ms)
PSS:Proportional Set Size 實(shí)際使用的物理內(nèi)存(比例分配共享庫占用的內(nèi)存),比如2個(gè)進(jìn)程使用10KB的共享庫,那么每個(gè)進(jìn)程算5KB內(nèi)存占用到PSS中。
Total PSS by process
這個(gè)標(biāo)簽下面的就是按照以PPS方式統(tǒng)計(jì)的衷畦,進(jìn)程使用內(nèi)存按多到少排列出來。
Total PSS by OOM adjustment:
這個(gè)下面是按OOM adj值排列的知牌,就是lowmem kill時(shí)的優(yōu)先級(jí)祈争,從高到低排列
依次對(duì)應(yīng)如下adj值,具體含義見注釋:

android/frameworks/base/services/core/java/com/android/server/am/ProcessList.java

    // Adjustment used in certain places where we don't know it yet.
    // (Generally this is something that is going to be cached, but we
    // don't know the exact value in the cached range to assign yet.)
    static final int UNKNOWN_ADJ = 1001;

    // This is a process only hosting activities that are not visible,
    // so it can be killed without any disruption.
    static final int CACHED_APP_MAX_ADJ = 906;
    static final int CACHED_APP_MIN_ADJ = 900;

    // The B list of SERVICE_ADJ -- these are the old and decrepit
    // services that aren't as shiny and interesting as the ones in the A list.
    static final int SERVICE_B_ADJ = 800;

    // This is the process of the previous application that the user was in.
    // This process is kept above other things, because it is very common to
    // switch back to the previous app.  This is important both for recent
    // task switch (toggling between the two top recent apps) as well as normal
    // UI flow such as clicking on a URI in the e-mail app to view in the browser,
    // and then pressing back to return to e-mail.
    static final int PREVIOUS_APP_ADJ = 700;

    // This is a process holding the home application -- we want to try
    // avoiding killing it, even if it would normally be in the background,
    // because the user interacts with it so much.
    static final int HOME_APP_ADJ = 600;

    // This is a process holding an application service -- killing it will not
    // have much of an impact as far as the user is concerned.
    static final int SERVICE_ADJ = 500;

    // This is a process with a heavy-weight application.  It is in the
    // background, but we want to try to avoid killing it.  Value set in
    // system/rootdir/init.rc on startup.
    static final int HEAVY_WEIGHT_APP_ADJ = 400;

    // This is a process currently hosting a backup operation.  Killing it
    // is not entirely fatal but is generally a bad idea.
    static final int BACKUP_APP_ADJ = 300;

    // This is a process only hosting components that are perceptible to the
    // user, and we really want to avoid killing them, but they are not
    // immediately visible. An example is background music playback.
    static final int PERCEPTIBLE_APP_ADJ = 200;

    // This is a process only hosting activities that are visible to the
    // user, so we'd prefer they don't disappear.
    static final int VISIBLE_APP_ADJ = 100;

    // This is the process running the current foreground app.  We'd really
    // rather not kill it!
    static final int FOREGROUND_APP_ADJ = 0;

    // This is a process that the system or a persistent process has bound to,
    // and indicated it is important.
    static final int PERSISTENT_SERVICE_ADJ = -700;

    // This is a system persistent process, such as telephony.  Definitely
    // don't want to kill it, but doing so is not completely fatal.
    static final int PERSISTENT_PROC_ADJ = -800;

    // The system process runs at the default adjustment.
    static final int SYSTEM_ADJ = -900;

    // Special code for native processes that are not being managed by the system (so
    // don't have an oom adj assigned by the system).
    static final int NATIVE_ADJ = -1000;

android/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java

    static final int[] DUMP_MEM_OOM_ADJ = new int[] {
            ProcessList.NATIVE_ADJ,
            ProcessList.SYSTEM_ADJ, ProcessList.PERSISTENT_PROC_ADJ,
            ProcessList.PERSISTENT_SERVICE_ADJ, ProcessList.FOREGROUND_APP_ADJ,
            ProcessList.VISIBLE_APP_ADJ, ProcessList.PERCEPTIBLE_APP_ADJ,
            ProcessList.BACKUP_APP_ADJ, ProcessList.HEAVY_WEIGHT_APP_ADJ,
            ProcessList.SERVICE_ADJ, ProcessList.HOME_APP_ADJ,
            ProcessList.PREVIOUS_APP_ADJ, ProcessList.SERVICE_B_ADJ, ProcessList.CACHED_APP_MIN_ADJ
    };
    static final String[] DUMP_MEM_OOM_LABEL = new String[] {
            "Native",
            "System", "Persistent", "Persistent Service", "Foreground",
            "Visible", "Perceptible",
            "Heavy Weight", "Backup",
            "A Services", "Home",
            "Previous", "B Services", "Cached"
    };

其中Cached標(biāo)簽下的進(jìn)程是隨時(shí)可以回收內(nèi)存的緩存進(jìn)程角寸,所以該部分內(nèi)存在后面會(huì)統(tǒng)計(jì)到Free RAM字段中

Total RAM: 1,530,604K (status normal)
 Free RAM:   775,291K (  118,227K cached pss +   139,608K cached kernel +   517,456K free)
 Used RAM:   690,302K (  609,662K used pss +    80,640K kernel)
 Lost RAM:    65,011K
   Tuning: 192 (large 192), oom   184,320K, restore limit    61,440K (high-end-gfx)

Total PSS by category:
該標(biāo)簽下統(tǒng)計(jì)系統(tǒng)中所有進(jìn)程每個(gè)類別占用內(nèi)存的總和菩混,具體每個(gè)的含義后面按app來解釋。

用adb shell dumpsys meminfo <pid> 命令來獲取單個(gè)進(jìn)程對(duì)應(yīng)的內(nèi)存信息:

** MEMINFO in pid 5304 [personal.jayhou.meminfodemo] **
                   Pss  Private  Private  SwapPss     Heap     Heap     Heap
                 Total    Dirty    Clean    Dirty     Size    Alloc     Free
                ------   ------   ------   ------   ------   ------   ------
  Native Heap     2737     2668        0        0     9728     8103     1624
  Dalvik Heap      635      576        0        0     2736     1200     1536
 Dalvik Other      428      428        0        0
        Stack      252      252        0        0
       Ashmem        5        0        0        0
    Other dev       14        0       12        0
     .so mmap     1601      120        0        0
    .apk mmap      564        0        0        0
    .ttf mmap       59        0        0        0
    .dex mmap     3987        4     2228        0
    .oat mmap      306        0        0        0
    .art mmap     4131     3800       88        0
   Other mmap       13        4        0        0
      Unknown      323      288        0        0
        TOTAL    15055     8140     2328        0    12464     9303     3160

 App Summary
                       Pss(KB)
                        ------
           Java Heap:     4464
         Native Heap:     2668
                Code:     2352
               Stack:      252
            Graphics:        0
       Private Other:      732
              System:     4587

               TOTAL:    15055       TOTAL SWAP PSS:        0

 Objects
               Views:       17         ViewRootImpl:        1
         AppContexts:        3           Activities:        1
              Assets:        2        AssetManagers:        3
       Local Binders:        9        Proxy Binders:       15
       Parcel memory:        3         Parcel count:       12
    Death Recipients:        0      OpenSSL Sockets:        0
            WebViews:        0

 SQL
         MEMORY_USED:        0
  PAGECACHE_OVERFLOW:        0          MALLOC_SIZE:        0

這個(gè)信息是在app進(jìn)程中打印出來的扁藕,最終該命令會(huì)執(zhí)行到對(duì)應(yīng)進(jìn)程的如下接口:

android/frameworks/base/core/java/android/app/ActivityThread.java

        @Override
        public void dumpMemInfo(ParcelFileDescriptor pfd, Debug.MemoryInfo mem, boolean checkin,
                boolean dumpFullInfo, boolean dumpDalvik, boolean dumpSummaryOnly,
                boolean dumpUnreachable, String[] args) {
            FileOutputStream fout = new FileOutputStream(pfd.getFileDescriptor());
            PrintWriter pw = new FastPrintWriter(fout);
            try {
                dumpMemInfo(pw, mem, checkin, dumpFullInfo, dumpDalvik, dumpSummaryOnly, dumpUnreachable);
            } finally {
                pw.flush();
                IoUtils.closeQuietly(pfd);
            }
        }

其中
Native Heap是指c 中malloc出來的堆空間
Dalvik Heap是指java中new出來的java堆空間

                   Pss  Private  Private  SwapPss     Heap     Heap     Heap
                 Total    Dirty    Clean    Dirty     Size    Alloc     Free
                ------   ------   ------   ------   ------   ------   ------
  Native Heap     2737     2668        0        0     9728     8103     1624
  Dalvik Heap      635      576        0        0     2736     1200     1536

這里可以看到Native Heap Pss Total列是2737 也就是native代碼中分配了2737KB的空間被占用 Heap Size列是9728沮峡,是指Native堆最大是這么多KB,后面還有Heap Alloc列是8103亿柑,這里是指在虛擬地址中分配了這么多空間邢疙,Dalvik Heap同理是指java中占用的空間,這里就奇怪了望薄,Pss Total和Heap Allock為啥不一樣呢疟游?
用Demo來試驗(yàn)下

public class MainActivity extends AppCompatActivity {
    private long[] m_8MB;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        m_8MB = new long[1024*1024];
        for(int i = 0; i < 1024*1024/2; i++) {
            m_8MB[i] = 0l;
        }
    }
}

如果沒有for循環(huán),只new long數(shù)組痕支,不賦值颁虐,則:

** MEMINFO in pid 6652 [personal.jayhou.meminfodemo] **
                   Pss  Private  Private  SwapPss     Heap     Heap     Heap
                 Total    Dirty    Clean    Dirty     Size    Alloc     Free
                ------   ------   ------   ------   ------   ------   ------
  Native Heap     2678     2608        0        0     8704     7725      978
  Dalvik Heap      587      528        0        0    15534     9390     6144

Dalvik Heap的HeapSize調(diào)整為了15MB左右,HeapAlloc增加了8MB卧须,正好是new long數(shù)組占用的空間另绩,但是注意Pss Total并沒有受到影響。
如果加上for循環(huán)給long數(shù)組一半的元素賦值:

** MEMINFO in pid 7099 [personal.jayhou.meminfodemo] **
                   Pss  Private  Private  SwapPss     Heap     Heap     Heap
                 Total    Dirty    Clean    Dirty     Size    Alloc     Free
                ------   ------   ------   ------   ------   ------   ------
  Native Heap     2658     2584        0        0     8704     7720      983
  Dalvik Heap     4687     4628        0        0    15534     9390     6144

可以看到Dalvik Heap下的Pss Total增加了4MB 其他沒變花嘶。
所以Pss Total是指占用了真實(shí)的物理內(nèi)存的空間笋籽,而Heap Alloc只是占用的虛擬內(nèi)存的空間。是分配了空間察绷,沒有使用的那部分內(nèi)存干签。

虛擬內(nèi)存:進(jìn)程空間內(nèi)的虛擬內(nèi)存地址津辩,理論上32位cpu一個(gè)進(jìn)程有4GB的虛擬內(nèi)存可以使用拆撼。
物理內(nèi)存:就是真正寫的到內(nèi)存條上的容劳,真實(shí)地址對(duì)進(jìn)程不可見,由操作系統(tǒng)把虛擬內(nèi)存地址映射到物理內(nèi)存地址闸度。

其他部分:

 Dalvik Other      428      428        0        0
        Stack      252      252        0        0
       Ashmem        5        0        0        0
    Other dev       14        0       12        0
     .so mmap     1601      120        0        0
    .apk mmap      564        0        0        0
    .ttf mmap       59        0        0        0
    .dex mmap     3987        4     2228        0
    .oat mmap      306        0        0        0
    .art mmap     4131     3800       88        0
   Other mmap       13        4        0        0
      Unknown      323      288        0        0

上面這部分顧名思義 Stack是指運(yùn)行中椊叻罚空間的使用(函數(shù)調(diào)用,局部變量等)莺禁,Ashmem是匿名內(nèi)存占用的空間留量,各種mmap是對(duì)應(yīng)類型文件加載部分占用內(nèi)存(可以部分加載也叫映射到內(nèi)存)

要查看詳細(xì)的內(nèi)存占用,可以查看:

adb shell cat /proc/<pid>/smaps
例如剛才的進(jìn)程7099實(shí)際使用的4MB內(nèi)存:

cd3ff000-cdc00000 rw-p 00000000 00:01 105348                             /dev/ashmem/dalvik-large object space allocation (deleted)
Size:               8196 kB
Rss:                4100 kB
Pss:                4100 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:      4100 kB
Referenced:         4100 kB
Anonymous:          4100 kB
AnonHugePages:         0 kB
Swap:                  0 kB
SwapPss:               0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB

Size:指的就是分配了多少虛擬內(nèi)存
Rss哟冬、Pss指的是實(shí)際物理內(nèi)存使用的大小楼熄,由于這個(gè)內(nèi)存段是純new出來的,沒有共享庫浩峡,所以這兩個(gè)值是一樣的可岂。由于只給4MB的數(shù)組賦值,操作系統(tǒng)只給分配了4MB的真實(shí)物理內(nèi)存翰灾。

把/proc/<pid>/smaps 所有數(shù)據(jù)段中Pss部分加起來缕粹,和上面所有類型的Pss加起的TOTAL行的Pss Total值是一樣的

        TOTAL:    15055

其他部分:

 App Summary
                       Pss(KB)
                        ------
           Java Heap:     4464
         Native Heap:     2668
                Code:     2352
               Stack:      252
            Graphics:        0
       Private Other:      732
              System:     4587

               TOTAL:    15055       TOTAL SWAP PSS:        0

 Objects
               Views:       17         ViewRootImpl:        1
         AppContexts:        3           Activities:        1
              Assets:        2        AssetManagers:        3
       Local Binders:        9        Proxy Binders:       15
       Parcel memory:        3         Parcel count:       12
    Death Recipients:        0      OpenSSL Sockets:        0
            WebViews:        0

 SQL
         MEMORY_USED:        0
  PAGECACHE_OVERFLOW:        0          MALLOC_SIZE:        0

App Summary部分換了一種方式統(tǒng)計(jì)Pss內(nèi)存占用,其Total值和上面部分一致纸淮。具體含義可以參考如下代碼:

android/frameworks/base/core/java/android/app/ActivityThread.java

        printRow(pw, ONE_COUNT_COLUMN,
            "Java Heap:", memInfo.getSummaryJavaHeap());
        printRow(pw, ONE_COUNT_COLUMN,
            "Native Heap:", memInfo.getSummaryNativeHeap());
        printRow(pw, ONE_COUNT_COLUMN,
            "Code:", memInfo.getSummaryCode());
        printRow(pw, ONE_COUNT_COLUMN,
            "Stack:", memInfo.getSummaryStack());
        printRow(pw, ONE_COUNT_COLUMN,
            "Graphics:", memInfo.getSummaryGraphics());
        printRow(pw, ONE_COUNT_COLUMN,
            "Private Other:", memInfo.getSummaryPrivateOther());
        printRow(pw, ONE_COUNT_COLUMN,
            "System:", memInfo.getSummarySystem());

android/frameworks/base/core/java/android/os/Debug.java

        /**
         * Pss of Java Heap bytes in KB due to the application.
         * Notes:
         *  * OTHER_ART is the boot image. Anything private here is blamed on
         *    the application, not the system.
         *  * dalvikPrivateDirty includes private zygote, which means the
         *    application dirtied something allocated by the zygote. We blame
         *    the application for that memory, not the system.
         *  * Does not include OTHER_DALVIK_OTHER, which is considered VM
         *    Overhead and lumped into Private Other.
         *  * We don't include dalvikPrivateClean, because there should be no
         *    such thing as private clean for the Java Heap.
         * @hide
         */
        public int getSummaryJavaHeap() {
            return dalvikPrivateDirty + getOtherPrivate(OTHER_ART);
        }

        /**
         * Pss of Native Heap bytes in KB due to the application.
         * Notes:
         *  * Includes private dirty malloc space.
         *  * We don't include nativePrivateClean, because there should be no
         *    such thing as private clean for the Native Heap.
         * @hide
         */
        public int getSummaryNativeHeap() {
            return nativePrivateDirty;
        }

        /**
         * Pss of code and other static resource bytes in KB due to
         * the application.
         * @hide
         */
        public int getSummaryCode() {
            return getOtherPrivate(OTHER_SO)
              + getOtherPrivate(OTHER_JAR)
              + getOtherPrivate(OTHER_APK)
              + getOtherPrivate(OTHER_TTF)
              + getOtherPrivate(OTHER_DEX)
              + getOtherPrivate(OTHER_OAT);
        }

        /**
         * Pss in KB of the stack due to the application.
         * Notes:
         *  * Includes private dirty stack, which includes both Java and Native
         *    stack.
         *  * Does not include private clean stack, because there should be no
         *    such thing as private clean for the stack.
         * @hide
         */
        public int getSummaryStack() {
            return getOtherPrivateDirty(OTHER_STACK);
        }

        /**
         * Pss in KB of graphics due to the application.
         * Notes:
         *  * Includes private Gfx, EGL, and GL.
         *  * Warning: These numbers can be misreported by the graphics drivers.
         *  * We don't include shared graphics. It may make sense to, because
         *    shared graphics are likely buffers due to the application
         *    anyway, but it's simpler to implement to just group all shared
         *    memory into the System category.
         * @hide
         */
        public int getSummaryGraphics() {
            return getOtherPrivate(OTHER_GL_DEV)
              + getOtherPrivate(OTHER_GRAPHICS)
              + getOtherPrivate(OTHER_GL);
        }

        /**
         * Pss in KB due to the application that haven't otherwise been
         * accounted for.
         * @hide
         */
        public int getSummaryPrivateOther() {
            return getTotalPrivateClean()
              + getTotalPrivateDirty()
              - getSummaryJavaHeap()
              - getSummaryNativeHeap()
              - getSummaryCode()
              - getSummaryStack()
              - getSummaryGraphics();
        }

        /**
         * Pss in KB due to the system.
         * Notes:
         *  * Includes all shared memory.
         * @hide
         */
        public int getSummarySystem() {
            return getTotalPss()
              - getTotalPrivateClean()
              - getTotalPrivateDirty();
        }

Objects是統(tǒng)計(jì)App內(nèi)部組件對(duì)象個(gè)數(shù)平斩,其中Views、ViewRootImpl以及Activities個(gè)數(shù)咽块,在Activity onDestroy后應(yīng)該都會(huì)回收清零绘面,如果onDestroy調(diào)用后這幾個(gè)對(duì)象個(gè)數(shù)沒有清零,就可能發(fā)生了內(nèi)存泄漏侈沪。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末飒货,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子峭竣,更是在濱河造成了極大的恐慌塘辅,老刑警劉巖,帶你破解...
    沈念sama閱讀 212,542評(píng)論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件皆撩,死亡現(xiàn)場離奇詭異扣墩,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)扛吞,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,596評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門呻惕,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人滥比,你說我怎么就攤上這事亚脆。” “怎么了盲泛?”我有些...
    開封第一講書人閱讀 158,021評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵濒持,是天一觀的道長键耕。 經(jīng)常有香客問我,道長柑营,這世上最難降的妖魔是什么屈雄? 我笑而不...
    開封第一講書人閱讀 56,682評(píng)論 1 284
  • 正文 為了忘掉前任,我火速辦了婚禮官套,結(jié)果婚禮上酒奶,老公的妹妹穿的比我還像新娘。我一直安慰自己奶赔,他們只是感情好惋嚎,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,792評(píng)論 6 386
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著站刑,像睡著了一般瘸彤。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上笛钝,一...
    開封第一講書人閱讀 49,985評(píng)論 1 291
  • 那天质况,我揣著相機(jī)與錄音,去河邊找鬼玻靡。 笑死结榄,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的囤捻。 我是一名探鬼主播臼朗,決...
    沈念sama閱讀 39,107評(píng)論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼蝎土!你這毒婦竟也來了视哑?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,845評(píng)論 0 268
  • 序言:老撾萬榮一對(duì)情侶失蹤誊涯,失蹤者是張志新(化名)和其女友劉穎挡毅,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體暴构,經(jīng)...
    沈念sama閱讀 44,299評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡跪呈,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,612評(píng)論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了取逾。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片耗绿。...
    茶點(diǎn)故事閱讀 38,747評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖砾隅,靈堂內(nèi)的尸體忽然破棺而出误阻,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 34,441評(píng)論 4 333
  • 正文 年R本政府宣布究反,位于F島的核電站寻定,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏奴紧。R本人自食惡果不足惜特姐,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,072評(píng)論 3 317
  • 文/蒙蒙 一晶丘、第九天 我趴在偏房一處隱蔽的房頂上張望黍氮。 院中可真熱鬧,春花似錦浅浮、人聲如沸沫浆。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,828評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽专执。三九已至,卻和暖如春郁油,著一層夾襖步出監(jiān)牢的瞬間本股,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,069評(píng)論 1 267
  • 我被黑心中介騙來泰國打工桐腌, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留拄显,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,545評(píng)論 2 362
  • 正文 我出身青樓案站,卻偏偏與公主長得像躬审,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子蟆盐,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,658評(píng)論 2 350