DonnyBrasco25 / androguard

Automatically exported from code.google.com/p/androguard
Apache License 2.0
0 stars 0 forks source link

Allocated memory of analysis cannot be cleaned up #135

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. ./androlyze.py -s
2. a = APK('com.badoo.apk')
3. d = DalvikVMFormat(a.get_dex())
4. gc.set_debug(gc.DEBUG_LEAK)
5. del d

What is the expected output? What do you see instead?
Expected: No uncollectable objects
Actual:   Many uncollectable objects

What version of the product are you using? On what operating system?
Version 2.0, Ubuntu 64 bit (Kernel 3.8.0-27-generic), Python 2.7.4

Please provide any additional information below.
I would expect the "del d" to mark the previously used memory as free again, so 
that it can be reused. But after several analysis with big apps, the memory 
consumption of androlyze grows dramatically (above 4gig), and further analysis 
crash with a MemoryError.

Original issue reported on code.google.com by dennis.t...@googlemail.com on 27 Aug 2013 at 6:40

GoogleCodeExporter commented 8 years ago
The problem seem to be reference cycles in the DAD decompiler. Attached is the 
memory usage of:

self.a = APK(apkobject.apkfile.name)
self.vm = DalvikVMFormat(self.a.get_dex())
self.vmx = VMAnalysis(self.vm)
self.vm.create_python_export()
self.dx = uVMAnalysis( self.vm )
self.gx = GVMAnalysis( self.vmx, None )
self.vm.set_vmanalysis( self.dx )
self.vm.set_gvmanalysis( self.gx )
self.vm.set_decompiler(DecompilerDAD(self.vm, self.vmx))
self.vm.create_xref()
self.vm.create_dref()

Original comment by julian.s...@gmx.net on 30 Aug 2013 at 8:40

Attachments:

GoogleCodeExporter commented 8 years ago
Um... DalvikVMFormat is not cleared. There are no collectable references left, 
but the reference counter is still not zero. 

>>> gc.collect()
0
>>> objgraph.by_type('DalvikVMFormat')
[<androguard.core.bytecodes.dvm.DalvikVMFormat object at 0xb3a3702c>]
>>> gc.get_referrers(objgraph.by_type('DalvikVMFormat'))
[]
>>> import sys
>>> sys.getrefcount(objgraph.at(0xb3a3702c))
171418

Original comment by julian.s...@gmx.net on 30 Aug 2013 at 7:09