Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android JNI local reference table, dump current state

Any Android JNI developer should be familiar with this wonderful message in logcat. My question is: how can I tell the VM to dump current table state? I need it for debugging purposes to make sure that native threads at exit have no outstanding local references.

like image 484
Pavel P Avatar asked Dec 01 '22 04:12

Pavel P


2 Answers

Full credit to Pavel, but I thought others might like the example code:

jclass vm_class = env->FindClass("dalvik/system/VMDebug");
jmethodID dump_mid = env->GetStaticMethodID( vm_class, "dumpReferenceTables", "()V" );
env->CallStaticVoidMethod( vm_class, dump_mid );
like image 82
JonnyBoy Avatar answered Dec 05 '22 00:12

JonnyBoy


In case somebody needs to do something similar, you can use dumpReferenceTables from dalvik.system.VMDebug

like image 20
Pavel P Avatar answered Dec 05 '22 02:12

Pavel P