2

The android documentation for the java.lang.Runtime class makes multiple reference to the JVM, for example calling the freeMemory() method:

Returns the amount of free memory in the Java Virtual Machine.

Yet in recent versions of android there is no virtual machine. What exactly does this method, and other similar methods, return?

  • just a note - I am not new to stack overflow, just a new account as the email linked to my old account has expired (university account) so no need for the inevitable welcome to SO comments. – James Callan Dec 03 '19 at 10:22
  • 1
    In case it wasn't obvious, the Android docs for a lot of the core JDK are effectively just copy-pasted. They have not been written specifically for Android, hence the incongruity. – Michael Dec 03 '19 at 10:32
  • 1
    You can ask merging this account with your previous one. Go to https://stackoverflow.com/company/contact – Dalija Prasnikar Dec 03 '19 at 10:35

1 Answers1

1

If I'm not mistaken, this is what gets call at the platform level from the Runtime::freememory() method: https://android.googlesource.com/platform/art/+/refs/tags/android-9.0.0_r51/openjdkjvm/OpenjdkJvm.cc#297 which then calls https://android.googlesource.com/platform/art/+/refs/tags/android-9.0.0_r51/runtime/gc/heap.h#548.

You can keep digging if you want to get to the very bottom of it, but it seems the ART is trying to provide a valid value to the calling app.

Jorge
  • 477
  • 2
  • 6