8

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?

JonasVautherin
  • 395
  • 1
  • 9
  • 19
  • The same for me on Linux Mint 17.1 and Ubuntu 14.04. Any updates? – yyunikov Apr 13 '15 at 15:37
  • I cannot say that this solved the problem, but I used the "File > invalidate cache and restart..." option from the menus (or something like that, I don't have it on top of my head). I also removed the ".gradle" directory. Which window manager do you use? – JonasVautherin Apr 13 '15 at 18:58
  • Now I use Cinnamon, but the same thing was on Unity and Gnome on Ubuntu 14.04. So it seems to be some common Android Studio issue for multiple Linux OS. – yyunikov Apr 13 '15 at 19:01
  • I also use "File > Power Save Mode" in Android Studio and seems it works much better with this option on, but it is very hard to work with it, because Android Studio is very limited and not highlighting code. – yyunikov Apr 13 '15 at 19:08
  • Did you try to invalidate the cache and restart? – JonasVautherin Apr 13 '15 at 19:09
  • No, but I think that it will still appear later even if I invalidate the cache and restart, so I will need to do it again and again. Android Studio loads CPU and freezes so much that I can't even move the mouse for a couple of minutes, so I think it would be hard to press it even if it will freeze :) – yyunikov Apr 13 '15 at 19:12
  • Did you find a solution? – JonasVautherin Jun 25 '15 at 09:30
  • pkill -e adb if it reports it killed it, re-run the command until there's no more adb, use android studio as necessary and when you need to test, adb will be started by the IDE –  Sep 01 '15 at 08:54
  • So you think adb is freezing Java? – JonasVautherin Sep 01 '15 at 08:57
  • I am just experiencing the problem again, and `pkill -e adb` does not solve it, unfortunately. – JonasVautherin Sep 08 '15 at 13:37
  • @YuriyYunikov: Did you find a solution? – JonasVautherin Oct 20 '15 at 08:46
  • No, I had to install Android Studio on Windows to make it run normally :( – yyunikov Oct 20 '15 at 13:00
  • How is the Ram before, during large C++ compilation which unfreezes the JVM? Curious about Max Heap space. Also, is problem reproduced for fresh user, home folder? Have found fresh user account, Eclipse, other toolkits download helpful when at a loss. – kph0x1 Dec 22 '15 at 17:50
  • Before the large C++ compilation, the ram is staying around 2330-2350MB. During the compilation which unfreezes the JVM, it goes up to ~2800MB. I have 32GB on my system. – JonasVautherin Jan 06 '16 at 10:09

2 Answers2

0

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.

Usi
  • 153
  • 11
0

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.

JonasVautherin
  • 395
  • 1
  • 9
  • 19