Pergunta

Every so often I see a lot of

03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 11
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 12
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 13
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 14
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 15
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 16
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 16
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 16
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 16
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 16
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 16
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 16
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 16
03-18 16:40:18.729: W/dalvikvm(22567): JNI: pin count on array 0x413e4488 ([C) is now 16

I know that this is outputted by the following code

/*
 * If we're watching global ref usage, also keep an eye on these.
 *
 * The total number of pinned primitive arrays should be pretty small.
 * A single array should not be pinned more than once or twice; any
 * more than that is a strong indicator that a Release function is
 * not being called.
 */
if (kTrackGrefUsage && gDvm.jniGrefLimit != 0) {
    int count = 0;
    Object** ppObj = gDvm.jniPinRefTable.table;
    while (ppObj < gDvm.jniPinRefTable.nextEntry) {
        if (*ppObj++ == (Object*) arrayObj)
            count++;
    }

    if (count > kPinComplainThreshold) {
        LOGW("JNI: pin count on array %p (%s) is now %d\n",
            arrayObj, arrayObj->obj.clazz->descriptor, count);
        /* keep going */
    }
}

... in Jni.c - And I'm aware of it's meaning, but given that I'm not writing in native and thus can't explicitly release anything manually, and am generally tidy with objects etc (nulling, and even calling System.gc()), is this something I need to be concerned about? Or in fact, is there anything at all I can do about it anyway?

I'm only asking because I'm trying to track down a crash bug and eliminating all possibilities.

Thanks.

Foi útil?

Solução

Since you're not writing native code there may not be anything you can do about it.

As noted in the comment, the warning exists to help developers find cases where they are pinning memory (through e.g. GetCharArrayElements) and never releasing it. Since the pin count in the logs you included peaks at 16 and doesn't go higher, it's likely that "release" is being called, and the memory remains pinned because the code that pins it hasn't finished accessing the array (i.e. there are 15 "live" objects that have it pinned).

The pin table has a maximum total size of 1024. If that gets exceeded, the VM will report the problem vigorously (it will write a specific log message and then abort). If you're not seeing that, then these messages have nothing to do with your crash, and you can ignore them.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top