Last active
August 29, 2015 14:23
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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