Java process freezes until I use 100% CPU

The issue I encounter

When working on Android-Studio, Eclipse or even command-line Gradle, the Java software often freezes (even though usually it is after I update my system/change java). For Android-Studio and Eclipse, if I move to another desktop and come back, then it becomes a gray window and the interface never comes back, even after hours. I suppose it is a Java issue.

It does not always happen: I usually don’t have any problem for weeks until it appears again. I don’t understand what makes it stop: when it happens, I try to reboot my computer, change my Java JDK version, but it does not change anything. Then one day, I boot my computer and the problem has disappeared – for the next few weeks.

What I can observe

  • One CPU always stays at 100%
  • I cannot make a thread dump of Android-Studio (as described here): it freezes as well.
  • If I run a big C++ compilation while Android-Studio/Eclipse/Gradle is freezing (i.e. a compilation that takes all of my CPUs), then it stops freezing and I can continue my work until the next time (but it happens extremely often).

What I tried

  • I tried another Window Manager: I could reproduce the bug on XMonad and Fluxbox
  • I tried to export _JAVA_AWT_WM_NONREPARENTING=1 in /etc/profile.d/jre.sh
  • I tried to switch between java-7-jdk, java-7-openjdk, java-8-jdk, java-8-openjdk
  • I tried to run wmname LG3D
  • I tried to run pkill -e adb, as advised in the comments
  • I tried to jmap <pid> on the <pid> of Android Studio, but I have a “DebuggerException: Can’t attach to the process”
  • I tried to jcmd <pid> GC.run on the <pid> of Android Studio, but I have a “DebuggerException: Can’t attach to the process” and “Unable to open socket file: target process not responding or HotSpot VM not loaded”.
  • I tried to remove my .gradle directory
  • I tried to Invalidate and Restart Android Studio (but the problem does not look to be unique to Android Studio since I experienced it with Eclipse, too)

My configuration

I am on Arch Linux (but a similar issue has been reported on Linux Mint) with Awesome WM (I experience the same with XMonad and Fluxbox). As far as I remember, it has always been happening on this machine (I changed in October 2014). Before this, it was working on Debian (but with Awesome WM as well). I have updated Android-Studio many times (from around 0.8 to the latest version).

What could be happening? Or how can I figure out?

Related problems

I have recently found this post talking about a similar problem. I tried what he advises (i.e. I tried export LD_ASSUME_KERNEL=2.4.1; android-studio) but then Android Studio does not start at all. Is it possible that I also have a problem with NPTL?

Asked By: JonasVautherin

||

In the Environment Variables settings in eclipse create a System Variable called _JAVA_OPTIONS with the value -Xms256m -Xmx1024m or change the existing one to these values. This assumes you have sufficient memory available.

Answered By: Usi

I never found the answer to this question, but this problem hasn’t occured in months (maybe a year?).

I guess something fixed it, somehow.

I will therefore close the question now.

Answered By: JonasVautherin
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.