google / play-services-plugins

Plugins to help with using Google Play services SDK.
https://developers.google.com/android/guides/overview
Apache License 2.0
471 stars 138 forks source link

Memory leak over multiple builds from strict-version-matcher-plugin #156

Closed alsutton closed 7 months ago

alsutton commented 4 years ago

Describe the bug strict-version-matcher-plugin uses a List to store dependencies associated with with an Artifact. The plugin instance can be re-used over multiple builds and so each build the List grows and consumes more and more memory.

To Reproduce Steps to reproduce the behavior:

  1. Create a project which uses the google-services plugin and has a large dependency graph
  2. Use the gradle-profiler with an android-studio-sync profile
  3. Analyse the memory consumption.
  4. Watch com.google.android.gms.dependencies.DependencyInspector deep-usage grow with each build

Expected behavior The memory usage should plateau or saw-tooth as the graph is loaded and either reused or disposed and rebuilt.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Possible fix in PR #155

Nirvanchik commented 3 years ago

We suffered this bug as well. We saw tremendous slow down of Configuration stage (twice slower) of Gradle build and encreasing of it with every new build by 2 seconds (if daemon is running).

And this behavior was even if you don't apply plugin. Just existing of it in buildscript classpath of root project worsen bulid performance. Memory heap dumps were showing large consumption by com.google.gms

After update google-services to 4.3.4 it is not reproduced anymore.

Thank you for the fix.