Skip to content

Instantly share code, notes, and snippets.

@rocka
Created December 15, 2021 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rocka/c72e5e192ec8ced57d050cc7ae0d220b to your computer and use it in GitHub Desktop.
Save rocka/c72e5e192ec8ced57d050cc7ae0d220b to your computer and use it in GitHub Desktop.
dump JNI local reference table in Kotlin
// ref: https://stackoverflow.com/questions/13283649/android-jni-local-reference-table-dump-current-state
fun dumpReferenceTables() {
try {
Class.forName("dalvik/system/VMDebug").run {
val dumpReferenceTables = getDeclaredMethod("dumpReferenceTables")
val constructor = getDeclaredConstructor()
constructor.isAccessible = true
dumpReferenceTables.invoke(constructor.newInstance())
}
} catch (e: Exception) {
Log.i("VMDebug", e.message ?: "")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment