Gradle daemon hangs after multiple runs


#1

I’m using the gradle daemon bu it is extremely unstable on my system. I have to restart it every 5 to 10 runs. Eventually it just hangs at the startup with 100% cpu. I increase the JVM memory, but that did not alter the behavior.

I’m running open jdk7 on Ubuntu

OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.10.2) OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)


(Luke Daley) #2

Can you please take a stack dump of the daemon process when this happens and submit it here (via Github Gist or similar.

There are some instructions on how to do this here: http://stackoverflow.com/questions/10756105/how-to-get-a-complete-stack-trace-of-a-running-java-program-that-is-taking-100

Thanks.


(Alexej Kubarev) #3

Im having the same problem and this is happening whenever I’m using a plugint hat uses Apache FOP to generate PDF (all streams and stuff is closed when plugin task completes, so I doubt this is the problem). This has been working better in 1.9 from what i recall… but can’t guarantee it. Currently running Gradle 1.11.

Here is the JStack output…https://gist.github.com/AlexejK/9598166

Also worth mentioning that I’m on OSX 10.9 and whenever similar problem happens it creates a foreground application (this is how OSX interprets it) for the java process… When i kill that “app” via Cmd+Q it kills daemon process. This makes me think that for some reason java process for GradleDaemon becomes a fore-ground process and takes focus from terminal to itself.

I’ve been having the similar issue before when FindBugs Quality Assurance plugin was running on earlier versions of Gradle.

This problem causes me not to be able to re-run the same task twice without killing the daemon as for some reason i’m getting “cannot find resource” problems in the plugin… This error is only happeining when daemon is hanging…


(Luke Daley) #4

Hi Alexej,

I can’t see anything in the stack trace. Would you be able to provide the simplest possible build that I can use to reproduce this? That would help greatly.

Thanks.


(Alexej Kubarev) #5

Hi Luke,

I was just able to work around that by setting the following env variable:

export JAVA_TOOL_OPTIONS=’-Djava.awt.headless=true’

It seems that the plugin code that I be trying to do something “weird” and causes the Java process to fork and therefore become in foreground.

Like i mentioned, this problem i had with FindBugs but not anymore (not sure if this or similar option is being configured for FindBugs process). Anyways… This is my workaround for the process. If you want to try to replicate the behaviour and also see what the plugin does, its essentially the same thing as this plugin (the code is the same for the part that makes the process to become in foreground):

https://github.com/spring-projects/gradle-plugins/tree/master/docbook-reference-plugin

Generating any referencePdf from Asciidoc will without problem generate docbook xml but when the XML is converted to PDF (when Apache FOP starts working) this is when the process goes into foreground and becomes a problem on OSX…

But, once again… setting the headless property for tools seems to solve the problem… not sure if it will cause any problems for other tools/processes yet…