-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Out Of Memory with dagger 2.25.2 #1645
Comments
Hmm, my initial guess is that this is due to reading the KotlinClassMetadata for each module (required for the new Kotlin-specific features). I'll take a look at this and see if anything obvious shows up in profiling. |
I manage to compile by using gradle plugin 3.6.0-beta1. Will continue testing with this one. |
When switching to 3.6.0-beta1, does that fix just the OOM or does it also change the build speed as well? |
With 3.6.0-beta1 the build speed is back to how to was with the old dagger version. |
I still get Out of Memory Errors with dagger 2.25.2 and gradle plugin 3.6.0-beta02 |
I think that 3.6.0 helps (sometimes) just because in 3.6 were fixed a few regressions of 3.5 that cause higher memory usage, so most probably Dagger 2.25.2 has higher usage of memory, but it less visible on 3.6 which has lower usage of memory, but the problem still exists (as @chrisharris77 mentioned) |
Thanks, we're looking into this. It is likely that the extra Kotlin metadata processing we need to do for the object class and qualifier on fields support is taking the extra memory. |
R.java files (generated in 3.5) may cause very high memory usage. In 3.6 we generate R.jar so this should save quite a bit of memory in the javac compiler (which is used by KAPT). |
Subscribing, just started using 2.25.2 |
Still have out of memory after updating to 2.25.3 |
I got 3gb leaked from kapt (kotlinCompiler daemon). From the tree view seems from dagger codegen requestKinds |
Thanks for the heap dump. Looks like this is from a static cache in |
See #1645 The static RequestKinds cache causes a memory leak in gradle due to the persistent GradleDaemon. This CL removes that cache entirely, and instead fixes the root causes of the performance issues, by short circuiting InjectionSiteVisitor to abort early if the method is not injectable. This avoids a lot of unnecessary calls to RequestKinds.getRequestKind() for methods that are not injectable (e.g. aren't annotated with @Inject). The aggregated pprof results from 10 runs before and after changes in this CL are below. Before (s) After (s) Diff ----------------------------------------------------------------------------- ComponentProcessingStep.process 51.80 43.25 -16.5% RequestKinds.getRequestKind 8.48 0.33 -95.9% ----------------------------------------------------------------------------- RELNOTES=Fix memory leak with RequestKinds cache. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=286934462
See #1645 The static RequestKinds cache causes a memory leak in gradle due to the persistent GradleDaemon. This CL removes that cache entirely, and instead fixes the root causes of the performance issues, by short circuiting InjectionSiteVisitor to abort early if the method is not injectable. This avoids a lot of unnecessary calls to RequestKinds.getRequestKind() for methods that are not injectable (e.g. aren't annotated with @Inject). The aggregated pprof results from 10 runs before and after changes in this CL are below. Before (s) After (s) Diff ----------------------------------------------------------------------------- ComponentProcessingStep.process 51.80 43.25 -16.5% RequestKinds.getRequestKind 8.48 0.33 -95.9% ----------------------------------------------------------------------------- RELNOTES=Fix memory leak with RequestKinds cache. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=286934462
This should hopefully be fixed in 2.25.4. |
2.25.4 resolves the out of memory issue in our case. We have 70k+ lines in the generated dagger component. |
Thanks everyone. Will bump and will close this issue if we can confirm that the issue went away. |
I checked my heap dump from 2.25.4 and the leak went away. Thanks for the fix ! |
Hi, I recently tried to update to dagger 2.25.2 from 2.24. I'm having OOM during kapt.
I tried changing the configuration with way more memory and I notice that the annotation processing is around 2 to 3x slower compare to 2.24.
The project is pretty huge, almost fully in kotlin and have hundreds of modules
EDIT:
Having the issue with gradle plugin 3.5.1 but does not happen with 3.6.0-beta1
The text was updated successfully, but these errors were encountered: