-
Notifications
You must be signed in to change notification settings - Fork 20
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
Memory leak when using daemon #25
Comments
We've got Gradle daemon disabled to avoid this shutdown hook memory snowball issue. For anyone coming from google, if you see the following message a bunch of times on the console along with a sick/stuck Gradle process:
Then, try adding the following to your top-level
Hey @psxpaul, could org.gradle.api.invocation.Gradle#buildFinished be a possible substitute for shutdown hooks in your plugin? |
Thanks for the feedback @woldie. I believe I used a shutdown hook because the stop must be run when the user presses ctrl-c to kill the process. I suspect calling Runtime.removeShutdownHook() would help, but I'm not able to reproduce this locally. Can you provide more information on how to reproduce this? Or perhaps try adding that call to AbstractExecFork.stop() and seeing if that fixes it for you? |
Hello to replicate this issue it should be enough to run some execfork task several times with using daemon and then do heapdump of that daemon process and there should be multiple threads saved as shutdown hooks even after build is done. |
Hi @psxpaul, We faced this issue on our CI infrastructure and running without a daemon is not an option. After digging into the source code I've found that ForkTaskTerminationService implemented in #45 is already tracking the processes and cleans them up post build - this works nicely with daemon and the wrapper. I think you could remove these lines and leave cleaning up for the service. The only use cases it would leave started processes is:
If you would really want to leave the hook in there you could register it, track it in the list and unregister in the service in the same way as tasks are tracked right now. |
I've added 8328794 to try to address this. Please try |
Hi @psxpaul , |
Saw this issue being easily reproducible locally with v0.2.0. Upgraded to v0.2.2. That's made the problem go away for my use case. Thanks. |
When using gradle daemon registered shutdown hooks are not run because task is run inside daemon which keeps running after build is done. And also stays in memory so new shutdown hooks are added with subsequent builds and filling heap until it runs out of heap space.
The text was updated successfully, but these errors were encountered: