我一直在尝试使用 Androguard 来分析 APK 文件。我的代码很简单:
from androguard import misc
from androguard import session
APK_TO_ANALYZE_PATH = r"file.apk"
a, d, dx = misc.AnalyzeAPK(APK_TO_ANALYZE_PATH)
print(" [*] Success")
APK 文件非常大,压缩后大约 150MB。但是,我的机器有 16GB 的 RAM,并且页面文件定义为最大 14GB,所以总的来说我有 30GB 的内存。
在尝试分析这个巨大的 APK 时,几分钟后我收到一个错误:
Traceback (most recent call last):
File "C:\Projects\ApkFiles\apk_analyzer.py", line 48, in <module>
main()
File "C:\Projects\ApkFiles\apk_analyzer.py", line 39, in main
a, d, dx = misc.AnalyzeAPK(APK_TO_ANALYZE_PATH)
File "C:\Python37-32\lib\site-packages\androguard\misc.py", line 69, in AnalyzeAPK
for dex in a.get_all_dex():
File "C:\Python37-32\lib\site-packages\androguard\core\bytecodes\apk.py", line 808, in get_all_dex
yield self.get_file(dex_name)
File "C:\Python37-32\lib\site-packages\androguard\core\bytecodes\apk.py", line 771, in get_file
return self.zip.read(filename)
File "C:\Python37-32\lib\zipfile.py", line 1432, in read
return fp.read()
File "C:\Python37-32\lib\zipfile.py", line 885, in read
buf += self._read1(self.MAX_N)
File "C:\Python37-32\lib\zipfile.py", line 975, in _read1
data = self._decompressor.decompress(data, n)
MemoryError
问题是什么?