Android Question How can a memory dump be aquired by using the android.os.Debug.dumpHprofData static method?

Silentsea

Member
Licensed User
Longtime User
I tried to create a litte wrapper function around the necessary reflection:

B4X:
Sub DumpHprofData(aDir As String, aFilename As String)
   If aDir = Null OR aDir = "" Then ThrowException("Parameter [aDir] must not be Null or empty").Throw
   If aFilename = Null OR aFilename = "" Then ThrowException("Parameter [aFilename] must not be Null or empty").Throw
   Dim aPath As String = File.Combine(aDir, aFilename)
    
   Dim r As Reflector
   r.RunStaticMethod( _
     "android.os.Debug", _
     "dumpHprofData", _
     Array As Object(aPath), _
     Array As String("[Ljava.lang.String;"))
End Sub

When it is called it throws an exception:
B4X:
java.lang.NoSuchMethodException: dumpHprofData [class [Ljava.lang.String;]
   at java.lang.Class.getConstructorOrMethod(Class.java:472)
   at java.lang.Class.getDeclaredMethod(Class.java:640)
   at anywheresoftware.b4a.agraham.reflection.Reflection.RunStaticMethod(Reflection.java:917)
   at maxcrash.crashcontrolstreet.ctools._dumphprofdata(ctools.java:521)
   ...

The android.jar path points to C:\Android\android-sdk\platforms\android-8\android.jar
So the API level should not be a problem.

Is there some other way to save hprof data out of a running program using an in-code method?

Versions:
B4A: 4.30
Reflection lib: 2.40
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…