DoraemonKit 【Android 10】Android Studio log: E/memtrack: Couldn't load memtrack module

whhtz7ly  于 4个月前  发布在  Android
关注(0)|答案(1)|浏览(138)

Android Studio frantically logs when using memory detection.
2021-03-30 16:15:14.876 9572-10483/com.didichuxing.doraemondemo.java W/android.os.Debug: failed to get memory consumption info: -1
2021-03-30 16:15:15.450 9572-10483/com.didichuxing.doraemondemo.java E/memtrack: Couldn't load memtrack module
2021-03-30 16:15:15.450 9572-10483/com.didichuxing.doraemondemo.java W/android.os.Debug: failed to get memory consumption info: -1
2021-03-30 16:15:16.026 9572-10483/com.didichuxing.doraemondemo.java E/memtrack: Couldn't load memtrack module
2021-03-30 16:15:16.026 9572-10483/com.didichuxing.doraemondemo.java W/android.os.Debug: failed to get memory consumption info: -1
2021-03-30 16:15:16.596 9572-10483/com.didichuxing.doraemondemo.java E/memtrack: Couldn't load memtrack module
2021-03-30 16:15:16.596 9572-10483/com.didichuxing.doraemondemo.java W/android.os.Debug: failed to get memory consumption info: -1
2021-03-30 16:15:17.171 9572-10483/com.didichuxing.doraemondemo.java E/memtrack: Couldn't load memtrack module
2021-03-30 16:15:17.171 9572-10483/com.didichuxing.doraemondemo.java W/android.os.Debug: failed to get memory consumption info: -1
2021-03-30 16:15:17.746 9572-10483/com.didichuxing.doraemondemo.java E/memtrack: Couldn't load memtrack module
2021-03-30 16:15:17.746 9572-10483/com.didichuxing.doraemondemo.java W/android.os.Debug: failed to get memory consumption info: -1
2021-03-30 16:15:18.318 9572-10483/com.didichuxing.doraemondemo.java E/memtrack: Couldn't load memtrack module
2021-03-30 16:15:18.318 9572-10483/com.didichuxing.doraemondemo.java W/android.os.Debug: failed to get memory consumption info: -1
2021-03-30 16:15:18.893 9572-10483/com.didichuxing.doraemondemo.java E/memtrack: Couldn't load memtrack module
2021-03-30 16:15:18.894 9572-10483/com.didichuxing.doraemondemo.java W/android.os.Debug: failed to get memory consumption info: -1
2021-03-30 16:15:19.467 9572-10483/com.didichuxing.doraemondemo.java E/memtrack: Couldn't load memtrack module
2021-03-30 16:15:19.467 9572-10483/com.didichuxing.doraemondemo.java W/android.os.Debug: failed to get memory consumption info: -1
2021-03-30 16:15:20.040 9572-10483/com.didichuxing.doraemondemo.java E/memtrack: Couldn't load memtrack module
2021-03-30 16:15:20.040 9572-10483/com.didichuxing.doraemondemo.java W/android.os.Debug: failed to get memory consumption info: -1

In DoraemonKit:

if (Build.VERSION.SDK_INT > 28) {
    memInfo = new Debug.MemoryInfo();
    Debug.getMemoryInfo(memInfo);
 }

try many phones which API > 28, got same results

Source from:
https://android.googlesource.com/platform/frameworks/base/+/master/core/jni/android_os_Debug.cpp
https://android.googlesource.com/platform/system/core/+/refs/tags/android-10.0.0_r34/libmemtrack/memtrack.cpp

System code as follow :

android_os_Debug_getDirtyPagesPid-> read_memtrack_memory-> memtrack_proc_get->android::sp memtrack = get_instance();->

static android::sp<IMemtrack> get_instance() {
static android::sp<IMemtrack> module = IMemtrack::getService();
    if (module == nullptr) {
        ALOGE("Couldn't load memtrack module");
    }
    return module;
}

This caused Log, but don't know why module == nullptr is nullptr, how can we fix it?

Info:
HUAWEI TNY-AL00 (Android 10)
Android:4.1.1

vwhgwdsa

vwhgwdsa1#

I also encountered the same problem. Is there a solution?

相关问题