启动服务时减少内存(EGL mtrack太大)

时间:2015-07-21 10:36:21

标签: android performance memory-management

首先我在清单上声明了服务:

   <service android:name=".TestService"
        android:process=":test">
    </service>

然后,我创建一个什么都不做的服务:

public class TestService extends Service{
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }
}

我用

开始了一项服务
mContext.startService(new Intent(mContext, TestService.class));

在我的应用程序中,然后我发现'Runing App'中的内存使用量(通过settings-&gt; apps-&gt;运行到达)是24M。这里是我得到的meminfo:

adb shell dumpsys meminfo com.mypush:test


Applications Memory Usage (kB):
Uptime: 79955214 Realtime: 87129943

** MEMINFO in pid 2452 [com.mypush:test] **
                   Pss  Private  Private  Swapped     Heap     Heap     Heap
                 Total    Dirty    Clean    Dirty     Size    Alloc     Free
                ------   ------   ------   ------   ------   ------   ------
  Native Heap     2508     2468        0        0    12288     4916     7371
  Dalvik Heap     1354      956        0        0    22320    16969     5351
 Dalvik Other      400      400        0        0                           
        Stack      136      136        0        0                           
      Gfx dev      628      628        0        0                           
    Other dev        4        0        4        0                           
     .so mmap      860      336        4        0                           
    .apk mmap       29        0        0        0                           
    .ttf mmap        9        0        0        0                           
    .dex mmap      156        0        4        0                           
    .oat mmap      191        0        0        0                           
    .art mmap      564      268        0        0                           
   Other mmap       36        4        0        0                           
   EGL mtrack    13888    13888        0        0                           
    GL mtrack     3272     3272        0        0                           
      Unknown      152      152        0        0                           
        TOTAL    24187    22508       12        0    34608    21885    12722

 Objects
               Views:        0         ViewRootImpl:        0
         AppContexts:        3           Activities:        0
              Assets:        3        AssetManagers:        3
       Local Binders:        8        Proxy Binders:       13
       Parcel memory:        3         Parcel count:       12
    Death Recipients:        2      OpenSSL Sockets:        0

 SQL
         MEMORY_USED:        0
  PAGECACHE_OVERFLOW:        0          MALLOC_SIZE:        0

我在Android 5.0 / Nexus5上运行,发现一些应用程序使用的服务使用的内存比我的少。所以我想知道为什么?

更新 我发现转储的EGL mtrack大约是13M,对于只有空服务的应用来说这是不正常的。

0 个答案:

没有答案