Problem
When updating Android Studio using patches, I get:
Temp. directory: C:\Users\user\AppData\Local\Temp\
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2271)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
from the updater.
Just a note: I am updating from 2.0 Preview 8 to 2.0 Preview 9, but I've had this issue for as long as I've used Studio, I think version 0.8 even. I'm aware I can just get a fresh copy of Android Studio, but I would prefer to download just 18 MB through the patch rather than the full 300 MB every time.
Progress
I believe I need to increase the heap size for the updater. I know I can do this through command line arguments, but I don't know where the updater is, nor how to run it.
I've tried increasing Java heap size through environment variables, but to no avail. It might not have worked on the updater somehow, so I want to try setting it directly.
Question
I'd like to know how to update with increased heap size. The file location of the updater jar would also be enough to get me started, and the full command to run would be brilliant.
I discovered that VM options can be modified for Android Studio as a whole, including the updater.
http://tools.android.com/tech-docs/configuration
Create your own .properties or .vmoptions files in the following
directories.
The folder name, referenced as {FOLDER_NAME} below, depends on the
version of Android Studio, usually AndroidStudiox.x
Windows:
%USERPROFILE%.{FOLDER_NAME}\studio.exe.vmoptions and/or %USERPROFILE%.{FOLDER_NAME}\studio64.exe.vmoptions
%USERPROFILE%.{FOLDER_NAME}\idea.properties
Mac:
~/Library/Preferences/{FOLDER_NAME}/studio.vmoptions
~/Library/Preferences/{FOLDER_NAME}/idea.properties
Linux:
~/.{FOLDER_NAME}/studio.vmoptions and/or ~/.{FOLDER_NAME}/studio64.vmoptions
~/.{FOLDER_NAME}/idea.properties
Increasing IDE Memory
By default, the IDE is assigned a maximum of 750 MB. If you have a
large project, or if you have a lot of RAM on your system, the IDE
will run better if you increase the amount of memory it is allowed to
use. To do that, create your own studio.vmoptions override (in the
location explained above) and add a line like this:
-Xmx2048m
Essentially, change updater options by changing Android Studio memory options, which helps Studio run better too!
Related
Whenever I start Android Studio and click on "open existing project" the file explorer opens, but then the whole application immediately freezes.
Im using Android Studio 3.1.3 and Ubuntu 16.04.
What could be the reason for this error?
There could be several reasons for this behavior. The first that comes to my mind is whether or not your hardware/OS meets the recommended specs - you can find the recommended specs below, taken from Android Studio's site:
GNOME or KDE desktop - Tested on UbuntuĀ® 14.04 LTS, Trusty Tahr (64-bit distribution capable of running 32-bit applications)
64-bit distribution capable of running 32-bit applications
GNU C Library (glibc) 2.19 or later
3 GB RAM minimum, 8 GB RAM recommended; plus 1 GB for the Android Emulator
2 GB of available disk space minimum,
4 GB Recommended (500 MB for IDE + 1.5 GB for Android SDK and emulator system image)
1280 x 800 minimum screen resolution
You could determine whether or not memory/CPU usage is the problem by issuing the following command when Android Studio is running:
-$top
-[SHIFT+M] (key combination that sorts processes by highest memory usage)
-[SHIFT+P] (key combination that sorts processes by highest CPU usage)
Bear in mind that the most likely memory offender of Android Studio will be Java and that's what you'll see in the top command output. If your memory usage is high, it's possible that your OS will start to use swap space which could significantly slow things down. To see how much swap memory is being used, issue the following command:
$free -h
This command will show you, at the time the command is issued, how much RAM and swap memory is being used in a human-readable format.
Another possibility that I have not experienced personally but have seen others have issues with is connected USB devices. Perhaps you have your phone connected - if this is the case try unplugging your USB connected device and then issue the following commands from a terminal (within the android_sdk/platform-tools directory):
$./adb kill-server
$./adb start-server
If you're not sure where the platform-tools directory is located, you can issue the following command:
$locate platform-tools
If Android Studio seems to start up/run without issue when the device is not connected, try reconnecting the USB device and see if the problem recurs.
It's also possible that what you're seeing is keyboard-related - i.e. the application stops responding to keyboard-input - this may be related to a known issue with the iBus Daemon - possible workarounds can be found at the following link:
http://tools.android.com/knownissues/ibus
If your problem is determined to be resource usage - it may be necessary to add more memory. If that is not the issue, it might be worth trying to completely reinstall Android Studio.
In case of misconfiguration, closing Android Studio and deleting .AndroidStudio3.1 configuration folder may help.
Find your configuration files | Android Developers
In some similar scenarios of misconfiguration deleting .idea folder might help.
Delete from command line the .android folder sudo rm -r /pathOfAndroidRootFolder/.android.
Try invalidate caches and restart option :
File -> Invalidate caches and restart
You can try deleting .AndroidStudio folder and check, because some java update might be needed for Android 3.1.3
I am using alloy4.2, and I am not able to tell it to use more memory.
I am not a Java expert and I suspect the problem is in how I'm configuring Java.
I am using OpenJDK Runtime Environment 1.8.0_131.
I have also tried 1.8.0_151.
My VM is running in Ubuntu x64.
Under the Alloy Options tab, Maximum Memory To Use is always stuck at the default of 768M.
I am using a VM that has 16G of memory available.
I have tried setting the Java stack parameters
-Xms1g and -Xmx8g
at the command line when I invoke Java, and also using the "export _JAVA_OPTS" to no avail.
Java says it is "picking up" the Xms and Xmx values and when I run
Java -XshowSettings:vm it shows that I have a max heap size of approx. 7.9G.
But Alloy doesn't let me increase the memory beyond the tiny minimum size of 768M. Any idea what I am doing wrong?
The numbers are hardcoded in Alloy although 4.2 should have 4Gb included? (There are a number of variants of 4.2 out there I think.)
We're working on creating a 5.0.0 version at the moment but that is not really publishable yet. You can download a snapshot JAR from:
https://oss.sonatype.org/content/repositories/snapshots/org/alloytools/org.alloytools.alloy.dist/5.0.0-SNAPSHOT/
I'm using the eclipse neon IDE and I put it on the path: /opt/eclipse/eclipse and i am using Ubuntu 16.04 and Java 8. The problem is that when I write in the eclipse editor, this is going too slow. For example, I just typed and in the editor it still does not end.
How can I solve it?
Thx!
Try Netbeans, or IntelliJ IDEA.
A quick browse over the Interwebs shows that quite a lot of people are complaining about Eclipse slowness. Some have every manner of trick and configuration change to help speed it up. OK, you can put yourself thru all that hassle if you want, or, you can just switch to something that already works fine out of the box.
I had Eclipse Oxygen for PHP running on a CentOS 7 VM with 2G allocated RAM. I admit, that's pretty low memory, but that's the way it has to be right now. Eclipse ran so slowly, I finally gave up and killed the process from the command line.
I installed the latest Netbeans 8.2, and it not only installed more cleanly (no Java error messages, and it put an icon on the desktop), it ran PERFECTLY without changing a thing!
I eventually changed a couple of parameters, but the point is, I didn't need to change a thing to get decent performance. Even on a low-ram system, it ran plenty fast enough.
Don't blame the hardware. Not everybody has the money to buy the latest and greatest and fastest machines available, and software developers should not expect it. With some exceptions, if your application can not run adequately on 2G of ram, you are doing something wrong.
The Eclipse developers are doing something terribly wrong.
I had faced a similar issue with eclipse oxygen.
After a some research over different forums I found the following solution.
Step 1 : Open eclipse.ini file. If you find difficulty in locating the file, see this question Where's the location of the eclipse.ini file?
Step 2 : In eclipse.ini search for below 2 variables
-Xms
-Xmx
Xms indicates minimum ram that should be allocated to eclipse.
Xmx indicates maximum ram that should be allocated to eclipse.
Step 3 :Increment both the values. You can set the value as per your choice. Below is my preference.
-Xms512m
-Xmx2048m
Here
m indicates megabytes, if you don't specify m it will consider bytes by default.
The easiest thing to do would be to re-install eclipse, and if that does not work you could try to download an older version of eclipse. It could also be slow because your computer is slow.
I start my java program (it creates a fullscreen movie in foreground) on the Windows 7 PC (64 bit, i5 processor).
Using the Process Explorer I saw that problem in that java.exe creates MSVCR100.dll threads that excessive use CPU.
I'm searching any solutions: remove .dll library from different places in Windows (system32, sysWOW64 folders) and this help to decrease CPU load to 10-20%
but afterwards this library loaded from JDK folder (C:\Program Files (x86)\Java\jdk1.8.0_60\jre\bin\msvcr100.dll) and everything begins the same.
I'm also increased Java maximum heap size:
-Xmx1024m
But it also didn't help.
Can anyone help me with that problem?
Looks like I figured out. Thread dump does't help me, but I use Sampler CPU tab in VisualVM tool. It show me the list of classes that by priority moustly load my CPU PC.
when trying to start eclipse, i receive the message in the image.
when trying to start other instance of eclipse, i receive a message saying: "failed to create the java virtual machine".
How can i solve it?
try starting eclipse with -clean option
./eclipse -clean
If it still doesn't start check ".log" file for error. This file should be located in "workspace/.metadata" folder. Publish error from log to your question.
Also check Java version and JAVA_HOME and PATH on your system are set accordingly. Java version should be at least 1.5
The message "failed to create the java virtual machine" usually implies the failure to allocate enough memory for starting the JVM. This is often due to unavailability of sufficient contiguous free memory in RAM, or incorrect min and max heap sizes.
From the screenshot, it appears that the problem might not be with the min and max heap sizes, so you might want to take a look at the amount of free memory available when starting Eclipse (although that is no indicator of whether all free memory is contiguous).
To begin fixing this issue, you could start Eclipse from the command-line and observe the error messages reported if any. Then you could proceed to calibrate the JVM settings that are better suited to your installation (heavy plugins will require more memory), or change to another JVM.
See also
Why does Eclipse crash with Xmx, XX:MaxPermSize above certain values?
What are the best JVM settings for Eclipse?
Go to C:\Program Files\Java\jre6\bin\client\ and make sure that jvm.dll exists there.
Either way, you might want to try re-installing or updating Java on your machine.
To modify file eclipse/eclipse.ini, try a smaller number in attribute -Xmx, and restart.
Check your version of Java. Oracle accidentally broke Eclipse when they updated the vendor field from 'Sun Microsystems' to 'Oracle'.
http://insideria.com/2010/08/oracle-breaks-eclipse-and-flex.html
Oracle was nice enough to change it back and release an update, which fixes Eclipse.
I had a similar problem when I installed JDK 64-bit version with an install of Eclipse 32-bit (didn't realize it until much searching and searching). Simple solution, but a shot none-the-less.