IntelliJ IDEA: the first compilation takes a lot of time - java

I'm using IntelliJ IDEA to develop my Java application. I'm frustrated with the fact that the first compilation of a project (or a complete rebuild) takes very long, about 15 min (and is very CPU-intensive). The project is composed from a couple of hundreds of Java classes, but compiling it with Eclipse just need 1-2 minutes.
Are there any compilation options that I can set in order to speed up this step?
UPDATE
My configuration: SSD, 64GB RAM, Xeon E5-1660, Win 7 Ultimate
Compilation time (Rebuild):
Eclipse: 30s
IntelliJ IDEA with Eclipse compiler 45s
IntelliJ IDEA with javac compiler: more than 10 minutes (!)
Number of java classes ~5000

Change the following setting (Build process heap size) to some large value

You can use the Eclipse compiler from IntelliJ IDEA.
Enable the Eclipse compiler from Settings -> Compiler -> Java Compiler: "Use compiler:" (change from Javac to Eclipse).
update: Here's my compilation times for a full rebuild, using IntelliJ IDEA 13 on a fairly large project:
Using javac 1.7.0_45 to compile java sources
Compilation completed successfully with 60 warnings in 27 sec
Using eclipse compiler to compile java sources
Compilation completed successfully with 652 warnings in 26 sec
So there seems to be something strange with your setup.

Answer from IntelliJ Support:
Try 13.0.2 from
http://confluence.jetbrains.com/display/IDEADEV/IDEA+13+EAP .
Disable the option to clean output directories on rebuild in the
compiler settings.

You can also increase the heap size in the file Intellij IDEA\bin\idea.exe.vmoptions. For example try these (assuming you have a lot of RAM):
-Xmx6g
-Xms6g
-XX:MaxPermSize=512m
-ea
-server
-XX:+UseConcMarkSweepGC
Having done this, you need to start idea with idea64.exe because the default 32bit version will not be able to use the big ram.

We put our projects on a SSD drive and this speed up the IDEA
rebuild significantly (about half the time).
I don't think you are comparing the same thing IDEA <-> eclipse somehow eclipse must have done some work already in the background or has a cache somewhere but I don't know eclipse well.

Related

IntelliJ - Use JDK 11 and Eclipse Compiler

I use IntelliJ 2018.3 and I need to use JDK 11.
The project compile on Eclipse (the Eclipse compiler) but not on IDEA (the Javac compiler)
So I decide to use Eclipse compiler on IDEA (Eclipse compiler 4.7.2) but I have always this error :
Is there any solution to compile my programm on IntelliJ with the Eclipse compiler and if yes, How can I do that ?
Use JDK 9 or lower, it's not supported for Java 10 and 11 yet: https://youtrack.jetbrains.com/issue/IDEA-190791 (Eclipse compiler specific limitation).
You can increase the heap size of the JVM running the build process and switch back to javac compiler instead of using Eclipse compiler:
This should fix the first error.
To resolve OutOfMemoryError during javac compilation you can pass the command line flags -J-Xms256m -J-Xmx256m to increase the memory.
This can be done in Settings > Build, Execution, Deployment > Compiler > Java Compiler menu under Additional Command Line Parameters field.

Extremely slow filesystem access in Eclipse using SSD

I have a project with lots of files. After switching to an SSD disk, things became impossible, its extremely slow. I reinstalled, upgraded to a new version (oxygen) but nothing changes.
For example, a refresh of workspace can take 10 minutes. A single file renaming, 5 minutes. But sometimes (it happens occasionally) these operations are really fast.
My OS is Debian 4.9.30-2+deb9u5 (2017-09-19) x86_64.
Eclipse build information:
Eclipse Java EE IDE for Web Developers.
Version: Oxygen.1a Release (4.7.1a)
Build id: 20171005-1200
OS: Linux, v.4.9.0-3-amd64, x86_64 / gtk 2.24.31
Before the SSD disk switch, I had no problem.
I had a similar issue. What fixed it for me was running Eclipse in clean mode, to clear out cached data. The first time you do eclipse -clean it takes ages, but then it's fast again. You should only have the -clean flag on once, not every time you run it.
Take a look at this answer for details: How to run eclipse in clean mode? and what happens if we do so?

Intellij IDEA 12 slow response

I've upgraded to IDEA 12 and become frustrated with the slow response. Class navigation takes several seconds to populate the search list (previously it was instantly), any dialog relevant to file list operation hangs for minutes. Move a class to another package just hang up and I have to kill the process. Does anyone have the same experience with me?
Additional information:
I am on windows 7
I tried both 64 and 32 versions and both have the same issue
My 64bit vmoption file has the following configuration:
I have the log dir zipped and put on http://ge.tt/1JwgAnU/v/0. When I start to generating the log dir, I clean it first and then start IDEA 64 bits, open a project (automatically), then invoke File > import module command. I observed there are around a minutes delay before the dialog popped up. And inside the log dir I see a threadDumps-20130106-091041-IU-123.100 folder. However there is no exception found in the idea.log file.
Updates
A screenr showing IDEA hang up when trying to move one class to another package by drag and drop: http://www.screenr.com/zlA7
I found the problem is caused by JDK 8 ea installed in my windows 7. IDEA use exe4j to load JDK, which automatically picked up JDK 8 (See this question).
After I defined IDEA_JDK_64 environment variable and point that to my JDK 6, a high performance IDEA comes back!
I had the exact same, but solved it by changing a setting the idea64exe.vmoptions:
from...
-XX:ReservedCodeCacheSize=64m
...to...
-XX:ReservedCodeCacheSize=256m
I had this problem with RubyMine (uses the same codebase) and it was because my system had swiched to OpenJDK instead of Sun/Oracle JDK.
I see that someone had similar problems in this thread: OpenJDK or Sun Java for IntelliJ IDEA
Specifically, do you see something like the following when you start your IDE from the terminal?
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b24~pre2-1)
OpenJDK Server VM (build 20.0-b12, mixed mode)
WARNING: You are launching IDE using OpenJDK Java runtime.
THIS IS STRICTLY UNSUPPORTED DUE TO KNOWN PERFORMANCE AND GRAPHICS PROBLEMS!
NOTE: If you have both Oracle (Sun) JDK and OpenJDK installed
please validate either IDEA_JDK, JDK_HOME, or JAVA_HOME environment variable points to valid Oracle (Sun) JDK installation.
See http://ow.ly/6TuKQ for more info on switching default JDK
Press Enter to continue.
Perhaps you should check if the upgrade caused the IDE to revert to a non-Oracle JDK.
In my case it was a Findbugs plugin that caused frequent lags. You can see this if you run IDEA from the terminal and look at the log output, e.g.
No classfiles specified; output will have no warnings
After disabling the real-time Findbugs scans (Settings -> Inspections -> Findbugs IDEA) everything ran smoothly again.

Ant parallel performance

I need to compile many similar SWFs in my project. I have ant build file, where I run mxmlc (flex compiler) tasks. To decrease general build time I want to run the tasks parallel. I have 4 core cpu.
<parallel threadsperprocessor="1" failonany="true">
If I don't use parallel compilation, then it takes ~12 sec to compile one swf. But when I try to run it parallel (4 cores => 4 threads at a time), the compile time of each swf is ~20 sec and while ant is running I have terrible lags of whole OS. Important: I've just reinstalled my OS (windows 7 64), and before it everything worked fine (no lags, fast 12sec compilation with 4 threads). By the way, if I set threadcount="2", then it is also OK, but I want to do it in 4 threads.
I guess It might be some java memory issues. I'm using now (and used before) -Xmx1024m -Xms256m
Please, help me to configure my JVM to make my build fast.
Ok, I've managed. Installed x86 JRE instead of x64. I have no idea why it didn't work for x64...

java heap space

do you have any idea why I could get a 'Exception in thread "main" java.lang.OutOfMemoryError: Java heap space' error when building my android app, even though I added -vmargs -Xmx1024M -Xms512M to the eclipse arguments ?
I would like to know what error could I have made that would trigger such an error at build time, as it would appear to me that only a bug in eclipse or maven could produce such an error at build time.
I am using run as maven install to build my application (with the maven android eclipse plugin). Run as-> 'maven package' also produces the same build failure, after waiting roughly 1min30.
I have a desktop computer with 3GB of memory, and my application isn't nearly that big.
Thanks.
Add -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/some/path to your jvm args so that when it runs out of memory it will dump out the heap. You can then use Eclipse Memory Analyser or jhat to browse the heap and diagnose where the problem might be.
Update: Try increasing the memory of your maven android plugin. In your pom.xml, add a JVM argument for Xmx to the plugin configuration:
<plugin>
<artifactId>maven-android-plugin</artifactId>
<configuration>
<jvmArguments>
<argument>-Xmx1500m</argument>
</jvmArguments>
</configuration>
</plugin>
Your Eclipse JVM arguments do not matter. You have to increase the heap of the compiler.
I am quoting http://javahowto.blogspot.com/2006/06/fix-javac-java-lang-outofmemoryerror.html
If [...] you're running Eclipse, go into your "run As" dialog for your Build.xml and add -Xms256m -Xmx256m to the "VM Arguments" text box
I experienced this Conversion to Dalvik format failed: Unable to execute dex: Java heap space. increasing the all of the values in the eclipse.ini file didn't help. This happened to me after I upgraded my ADT plugin from 12 to 16. I changed the Android SDKs that were pointed to my existing projects prior to the upgrade (from the android sdks that were connected on my previous adt I changed them to the android sdks that were connected to my new adt) and it solved the issue for me. hope this helps. and if it helps someone please vote for plus 1 this.
If increasing does not respond then I would suggest to you that check the line count for each class you wrote. It can be a compiler problem if there are a lot of objects so try to partitioning methods and/or copy them into new classes if one or more of the classes have 3000+ lines.

Categories