I noticed a lot of ResolverAAImpl.instance ThreadLocals being left over. This variable should be cleared out when processing is done, since it holds on to a lot of memory. This memory is then not available to other Gradle tasks that run later.
It's created here and should probably be unset in the finally block of that same method. I didn't search for other ThreadLocals in the code base, but if there are more, the same reasoning applies.