Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MemLogging.java « log « util « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8bb7e8927dfc064460ead88432af807a17f1f9e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.mapswithme.util.log;

import android.app.ActivityManager;
import android.content.Context;
import android.os.Debug;
import android.os.Build;
import com.mapswithme.maps.MwmApplication;


public class MemLogging
{
  public static String getMemoryInfo()
  {
    final Debug.MemoryInfo debugMI = new Debug.MemoryInfo();
    Debug.getMemoryInfo(debugMI);
    final ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    final ActivityManager activityManager =
            (ActivityManager) MwmApplication.get().getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
    activityManager.getMemoryInfo(mi);

    StringBuilder log = new StringBuilder("Memory info: ");
    log.append(" Debug.getNativeHeapSize() = ").append(Debug.getNativeHeapSize() / 1024)
      .append("KB; Debug.getNativeHeapAllocatedSize() = ").append(Debug.getNativeHeapAllocatedSize() / 1024)
      .append("KB; Debug.getNativeHeapFreeSize() = ").append(Debug.getNativeHeapFreeSize() / 1024)
      .append("KB; debugMI.getTotalPrivateDirty() = ").append(debugMI.getTotalPrivateDirty())
      .append("KB; debugMI.getTotalPss() = ").append(debugMI.getTotalPss())
      .append("KB; mi.availMem = ").append(mi.availMem / 1024)
      .append("KB; mi.threshold = ").append(mi.threshold / 1024)
      .append("KB; mi.lowMemory = ").append(mi.lowMemory);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
      log.append(" mi.totalMem = ").append(mi.totalMem / 1024).append("KB;");
    }
    return log.toString();
  }
}