Dump memory heap on OOM error in tool wrapped by exception that fails gradle build

Hi guys,

I’m trying to troubleshoot my failing gradle build:

> There was a failure while executing work items
   > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
      > java.lang.reflect.InvocationTargetException (no error message)

With --stacktrace I see issue:

Caused by: android.databinding.tool.util.LoggedErrorException: failure, see logs for details.
cannot load api descriptions from /Volumes/SDCard/Android/sdk/platform-tools/api/api-versions.xml java.lang.OutOfMemoryError: GC overhead limit exceeded

I wonder if I can somehow get memory dump of the error?

Oke, it was fairly easy. Start VisualVM, click gradle worker deamon and ask to dump memory on OOM.

A lot of other methods here https://dzone.com/articles/how-to-capture-java-heap-dumps-7-options