Skip to content

Instantly share code, notes, and snippets.

@inl1ne
Last active August 29, 2015 14:23
Show Gist options
  • Save inl1ne/577296bdb4d8ffa16ff5 to your computer and use it in GitHub Desktop.
Save inl1ne/577296bdb4d8ffa16ff5 to your computer and use it in GitHub Desktop.
A pseudocode explanation of why class instance counting is slow on Android Lollipop
// StrictMode.conditionallyCheckInstanceCounts
force_garbage_collection // because I don’t trust VMDebug to get this right
foreach(c in classes) {
// VMDebug.countInstancesofClass()
force_garbage_collection // because I don’t trust my caller to get this right
classes2.add(c)
// Heap::CountInstances
visit objects (obj =>
foreach(c2 in classes2) {
if (c2 is assignable from obj.class) {
increment c2 instance count
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment