Search code examples
androidmemory-leaksandroid-sourceandroid-automotive

AOSP emulator memory filling up very quickly


I'm currently working with AOSP and building an app for the Android Automotive OS. I have compiled the same code (checked out from version control) on two different PCs (both running Ubuntu). On one of them (with an Intel CPU) the emulator starts up fine and the emulator is stable.

On the other PC (an AMD CPU) the emulator starts up, but will quickly crash with OutOfMemory errors. AOSP is quickly killing all processes, then its system processes and finally reboots due to 'System is deadlocked on memory'.

I found that the culprit is a system process. It hoards a lot of memory: the android.hardware.automotive.vehicle process is hoarding memory. It keeps growing very quickly and finally the OS reboots.

When I use the meminfo tool to inspect memory usage of the process, I find the following: The android.hardware.automotive.vehicle process is using over 2GB of RAM.

My questions thus are:

  1. Do you what is happening?
  2. How can I debug this system process?
  3. Why is the system process behaving differently on one PC compared to another PC?

Solution

  • For those who ran into this issue:

    After a lot of fiddling around, I found that adding custom vehicle properties to the VHAL definitions (think of the types.hal and DefaultConfig.h files) must be done very carefully. In my case, I added a vehicle property with VehiclePropertyChangeMode set to CONTINUOUS, but did not add a minimum and maximum sample rate. This caused the android.hardware.automotive.vehicle service to keep requesting more and more memory for some reason and finally the emulator would crash.

    If you want to prevent this from happening, make sure to add a minSampleRate and maxSampleRate in your DefaultConfig.h file!