Search code examples
androiddalvikvm-implementationandroid-runtime

Android Runtime(ART) is virtual machine?


I wonder if ART is virtual machine. The dex2oat compiles dalvik byte code into the native (specific for platform) code, elf file. So as mentioned in android developer article it still has garbage collector. I don't understand how does it work, we have native compiled elf file, but it still runs in virtual machine environment ? How does GC work in this case ? Please give a good reference to read about this or please explain this. Thanks in advance.


Solution

  • GC is just a way the memory is managed. In any Java VM GC is the entity responsible for both memory allocation AND garbage collection. when you allocate an object GC check for available memory and collects garbage if there is no free space. You can implement the same algorithm in native language like C or C++. So it doesn't matter if you compile java to bytecode and then bytecode calls GC and GC runs inside JVM or you compile java to native code and link it with GC which may be a shared library. There was a VM from Miriad Group (ex Esmertec) which did it way before ART but for Java ME