a
554325746@qq.com
2019-12-25 603cb36a5123e46656b06a5deb8d7ac7ff81307f
app/src/main/java/com/basic/security/utils/MemoryUtil.java
@@ -5,10 +5,16 @@
import com.basic.security.base.BaseApplication;
public class MemoryUtil {
    static long lastTimePrint = 0;
    public static void monitorMemory() {
        if (1 == 1) {
            return;
        }
        if (System.currentTimeMillis() - lastTimePrint < 15 * 1000) {
            return;
        }
        lastTimePrint = System.currentTimeMillis();
        try {
            Runtime runtime = Runtime.getRuntime();
            long usedMemInMB = (runtime.totalMemory() - runtime.freeMemory()) / 1048576L;
@@ -20,7 +26,7 @@
            long getNativeHeapAllocatedSize = Debug.getNativeHeapAllocatedSize() / 1048576L;
            long getNativeHeapSize = Debug.getNativeHeapSize() / 1048576L;
            long getNativeHeapFreeSize = Debug.getNativeHeapFreeSize() / 1048576L;
            System.out.println(" " + "usedInMB=" + usedMemInMB + " " + Thread.getAllStackTraces().size()
            System1.out.println(" " + "usedInMB=" + usedMemInMB + " " + Thread.getAllStackTraces().size()
                    + " availHeapSizeInMB=" + availHeapSizeInMB + " getNativeHeapAllocatedSize=" + getNativeHeapAllocatedSize
                    + " getNativeHeapSize=" + getNativeHeapSize + " getNativeHeapFreeSize=" + getNativeHeapFreeSize
            );