ChairmanC / dex2jar

Automatically exported from code.google.com/p/dex2jar
0 stars 0 forks source link

Could it use a filestream instead of a full byte[]? #127

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use dexreader in Android app.
2. It will crash due to memory constraints when using twice. 
3.java.lang.OutOfMemoryError in readFileToByteArray

What is the expected output? What do you see instead?
Can't it use a stream instead of reading to a full byte[]? 
Also it looks like to leak memory, cause the first time it opens a apk on the 
device it goes well, second time it crashes. 

What version of the product are you using? On what operating system?
Android 4.0, dex2jar 0.0.9.8

Please provide any additional information below.

Original issue reported on code.google.com by goo...@umito.nl on 17 Jul 2012 at 1:21

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Yes, I understand that. But I looked through the code and saw that the whole 
file is read into a byte[]. Is that necessary? Can't it use a stream to work 
through the file? The visitor structure looks like it it doesn't need to have 
processed the whole file first. I would thought that dex2jar would be a 
streaming reader. You understand what I mean?

Original comment by goo...@umito.nl on 17 Jul 2012 at 3:30

GoogleCodeExporter commented 9 years ago
I tried asmdex, but that one gives even faster a outofmemory error. I can use 
dex2jar fine for smaller apps. 

Original comment by goo...@umito.nl on 17 Jul 2012 at 3:46

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Ok, that's a great solution. That looks like what I want to have. Unfortunately 
it gives me "not support magic", because I supply the apk file that is on the 
device and not the dex file that is unzipped normally when you use a normal 
File.

Original comment by goo...@umito.nl on 17 Jul 2012 at 7:37

GoogleCodeExporter commented 9 years ago
I created a DataIN that extends MemoryCacheSeekableStream that wraps the 
ZipInputStream to get the dex file from the apk ondevice, and that works! So I 
guess I'm done now. ;)

Original comment by goo...@umito.nl on 17 Jul 2012 at 8:55

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I have attached the files I used. Note that because seekablestream uses 
interface DataInput, the return type of readByte needs to be byte, not int. So 
I have changed that in DataIn and other classes that implement that interface. 
This change is not included in zip file. However, it's just changing return 
type (with eventual cast if necessary). It works great on my device now. To 
open APK file on device I use APKFileStreamerDataIn, also included.

Original comment by goo...@umito.nl on 18 Jul 2012 at 7:25

Attachments: