brazdil / dexter

1 stars 1 forks source link

App parsing becomes slower? #4

Closed xurubin closed 11 years ago

xurubin commented 11 years ago

It only takes 6 seconds to load 056-const-string-jumbo.apk using older version 430de9dc474210d31deb1aaed6d98092ae5b15da, but the HEAD now spend more than 80 seconds on it.

brazdil commented 11 years ago

The application has two classes that both have thousands of static fields. In the older version, their names were simply parsed and stored inside the instruction. Nowadays, Dexter looks up the field in the class hierarchy, which not only saves some memory (don't need to store the field name + type + parent class everywhere, one reference is enough), but also makes sure we're not analyzing something we don't have enough information about.

The reason why it was being SOOO slow was that I was doing a linear search through a HashSet of static fields during this lookup... Replace that with an ArrayList and it becomes significantly faster, but still takes a long time. I could make it even faster by using a HashMap, indexed by the FieldId object, but that would again increase the memory usage.

So I think I'll just leave the List there, because normal apps won't have that many fields...