Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run dump_classes_from_hprof.py KeyError #387

Closed
levianye opened this issue Mar 22, 2019 · 10 comments
Closed

run dump_classes_from_hprof.py KeyError #387

levianye opened this issue Mar 22, 2019 · 10 comments

Comments

@levianye
Copy link

levianye commented Mar 22, 2019

when I run dump_classes_from_hprof.py,wrong error as below
my python version is 2.7.15, os is macOS 10.14.2
and that is my command :python2 dump_classes_from_hprof.py --hprof mydump.hprof > list_of_classes.txt
what is this issue? anyone can help?
Traceback (most recent call last):
File "dump_classes_from_hprof.py", line 1265, in
hp = parse_filename(args.hprof)
File "dump_classes_from_hprof.py", line 57, in parse_filename
return parse_hprof_dump(open(filename, 'rb'))
File "dump_classes_from_hprof.py", line 49, in parse_hprof_dump
hprof_data.resolve()
File "dump_classes_from_hprof.py", line 889, in resolve
root.resolve(self)
File "dump_classes_from_hprof.py", line 304, in resolve
self.obj = hprof_data.object_id_dict[self.object_id]
KeyError: 328084648
and here is the my dump file
lenderdump.hprof.zip

@levianye levianye changed the title dump_classes_from_hprof.py error run dump_classes_from_hprof.py KeyError Mar 22, 2019
@wsanville
Copy link
Contributor

Hello, I apologize but it looks like this script has not been maintained or kept up to date. Therefore, it's unlikely to work on heap dumps from modern OS versions. We're likely to remove this soon, since we haven't been using it.

@levianye
Copy link
Author

levianye commented Mar 23, 2019

@wsanville my android phone is xiaomi mix2 ,android version 8.0,is cause of android version ?for modern OS versions what should I do now?dump heap from a lower os version?

@justinjhendrick
Copy link
Contributor

Yeah, the script doesn't support android 8. I think the script was written back when most android phones were 4.x. So it's pretty out of date.

@levianye
Copy link
Author

levianye commented Mar 26, 2019

@justinjhendrick Is that interdex option also worked at modern version? if I dump from lower version like 5.x or 4.x version ,is that dump from 5.x also ok?cause my oldest os version is 5.1. lower version dump analyzed by this script also worked at modern os version like android 8.0?

@levianye
Copy link
Author

levianye commented Mar 26, 2019

I dump from 5.1.1 also run error
Traceback (most recent call last):
File "redex/tools/hprof/dump_classes_from_hprof.py", line 1265, in
hp = parse_filename(args.hprof)
File "redex/tools/hprof/dump_classes_from_hprof.py", line 57, in parse_filename
return parse_hprof_dump(open(filename, 'rb'))
File "redex/tools/hprof/dump_classes_from_hprof.py", line 49, in parse_hprof_dump
hprof_data.resolve()
File "redex/tools/hprof/dump_classes_from_hprof.py", line 866, in resolve
clazz.resolve(self)
File "redex/tools/hprof/dump_classes_from_hprof.py", line 551, in resolve
static_field.value = hprof_data.object_id_dict[static_field.value]
KeyError: 6619237

5.1.1 also not work?
dumpfrom5.1.1.hprof.zip

since now dump not work at modern os version ,just run redex path/to/your.apk -o path/to/output.apk use default config is OK right?
cause I found apk is a bit smaller after redex,but I would like to accelerate start speed,is that default config is enough?according to your doc I think interdex pass is better

@justinjhendrick
Copy link
Contributor

Interdex should work okay on any android version. A dump from an older phone should still work on a newer phone (though, I doubt the optimal order is the same across many OS versions).

I'm not sure where that script works. My guess is that it might only work on 4.x devices.

@levianye
Copy link
Author

I gave up Interdex cause I can't handle it ,doc seems very simple I can't generate a dump classes for interdex config ,do you have any sample? it seem compatibility not very well,now I can only use default config for redex

@benjaminRomano
Copy link

What do you recommend to use as a replacement for this script? @justinjhendrick @wsanville

@justinjhendrick
Copy link
Contributor

I'd recommend building an instrumented version of your app that logs which classes are loaded (and in what order). Then you can use that data to generate a class list for interdex.

@emma0303
Copy link

We haven't updated this script, nor do we use it for a long time now.
But, when this was created, it was written for Android 4 heapdumps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants