I'm using PHPStorm under Win7 64bit with 64bit Java (latest version I guess) and working currently on an insanely big and chaotic project. There are many classes containing 10k LOC and more. Therefore my PHPStorm runs out of memory once in a while.
I get this nice Out-of-Memory dialog suggesting increasing my memory settings. I currently have set in my PhpStorm.exe.vmoptions:
-server
-Xms128m
-Xmx512m
-XX:MaxPermSize=250m
-XX:ReservedCodeCacheSize=64m
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+UseCodeCacheFlushing
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
The problem is: When I increase my memory to be used in this file I get the following error when starting the program:
Failed to create JVM: Error code -4
I Googled around but nobody seems to want the memory to be more than 512MB.
Does anybody know what I can do to use PHPStorm without any hassle again?
Sure, I can reset the cache but this is not a permanent solution, right?
I read somewhere that adding this line to my vmoptions is a good idea, but I don't see any difference:
-server
....
-XX:MinHeapFreeRatio=15
Changing memory settings for PHPStorm now has a menu option:
Make sure that PhpStorm use 64-bit Java and not bundled one (which is 32-bit). You an check that in Help | About.
Generally speaking: with 64-bit Java you do not have to change that value as it works a bit differently compared to 32-bit one.
1) PhpStorm comes with bundled x86 Java and it is the first one that it tries; only then it looks for other Java installations -- check PhpStorm.bat for details (what environment variables and in which order). By defining one of those environment variables (which will point to your 64-bit Java installation) you can tell PhpStorm to use instead of bundled one.
2) PhpStorm v8 (currently in EAP stage) comes with 64-bit specific files: you should use PhpStorm64.exe and not PhpStorm.exe (same for .vmoptions file -- it should be PhpStorm64.exe.vmoptions).
I'm not sure how PhpStorm v7 works with 64-bit Java -- have never tried it this way myself.
Selecting the JDK version the IDE will run under
https://intellij-support.jetbrains.com/entries/23455956-Selecting-the-JDK-version-the-IDE-will-run-under
After reading this post, I switched to 64bit version (after installing correct JDK) and increased designated memory to 2GB just to shut it up. But I still hit the ceiling, freezes et.c.
Eventually realized, that I had my bower_componentsfolder tracked. Folders like this with tons of javascript-files et.c. will basically eat all ram in the world (I also exclude node_modules folder now, same story). So I right-clicked the node_modules folder > Mark directory as > Exluded. After some garbage-collection, bumped PhpStorm's memory footprint down to 5-600mb, which seems reasonable.
PhpStorm 2016.1 and newer
As of PhpStorm 2016.1 instead of WEBIDE_JDK_64 one should use JAVA_HOME environment variable that should point to your JVM path.
Versions prior PhpStorm 2016.1
Like it was mentioned in the #LazyOne's answer, as of PhpStorm v8 (already released), you can use PhpStorm64.exe. But I wasn't able to find any description on how to specify the JVM path for it. The document that explains how to select the JDK version, seems to be a bit outdated.
After some research, I discovered that you should create WEBIDE_JDK_64 environment variable that should point to the JRE 64-bit installation path. After doing this, you will be able to start PhpStorm64.exe.
By default it sets max memory to 750mb. If you need more, you can modify the C:\Program Files (x86)\JetBrains\PhpStorm 8\bin\PhpStorm64.exe.vmoptions. The better idea, however, would be to edit your user's vmoptions file. Just copy C:\Program Files (x86)\JetBrains\PhpStorm 8\bin\PhpStorm64.exe.vmoptions to %USERPROFILE%\.IntelliJIdea12\idea.vmoptions and set -Xmx750m to a higher value.
Simply File > Invalidates Caches / Restart... works for me. 👌😀
Help -> Change Memory Settings -> Update Maximum Heap Size to desired value. This fixed issue for me.
I found a log file in the application which grew from a few KB to over 2 GB during a few seconds due to a bug. Webstorm was trying to index this 2 GB log file and running out of memory. Deleting the log file solved the problem (and then fixing the bug prevented the log file from growing).
Prior to this I also tried running the x64 JDK and increasing XMX to 2048. But in the end a 64 bit environment with 2048 MB wasn't enough (even though 512 MB was always enough before).
Related
I made changes to Intellij Community Edition (ce). I can compile and run those changes from within the IntelliJ editor. That launches a second instance of IntelliJ ce which is running from classes containing my changes. What I want to do is just run those changes without having to first load the source, compile and run from within IntelliJ.
Netbeans made this easy by just producing an executable as a result of the build. With Intellij, it's not at all clear what has to be done. I have tried the following-
using the Run configuration Intellij itself uses to run the altered classes- this includes setting the working directory , main class, vm options and classpath. Actually, this doesn't work for reasons unknown to me.
on someone's suggestion, running dist.gant in build. This blows up with very many errors which are not helpful (no class def found errors which indicate some confusion on Intellij's part on classpaths somewhere)
Running WinLauncher.exe under bin gives the error message that it can't find VM options file (although it's in bin, (and also for good measure under bin/win with the other files which are co-located with vmoptions in the intellij directory structure for Intellij proper. )
ALl this is just harder than it should be. The solution is to provide an executable as a result of the build and place it in a predictable location.
Has anyone ever actually DONE what I am trying to do- make changes to the community source then use the resultant editor not as a project you're working with in IntelliJ but as the Intellij editor you're working through?
FOLLOW UP
User60561 had the correct answer. Just to mop up the details, in artifacts, there is a compressed file (win.zip for Windows, mac.zip for Mac etc.). In order to run your snapshot, you have to unzip this archive (after which it will have the same name, minus the zip extension) then go into folder "bin". There you'll see two executables: idea.exe and idea64.exe, for 32 and 64 bit versions, respectively. Clicking on these runs your snapshot.
Adjusting contents of the files idea.exe.vmoptions and idea64.exe.vmoptions lets you set the VM parameters to suit yourself, typically people might want to give the VM more memory through the -Xmx value.
It seems straightforward:
To build the distribution archive of IntelliJ IDEA Community Edition, execute build.xml Ant build script in the root directory of the source code. The results of the build execution can be found at out/artifacts.
https://github.com/JetBrains/intellij-community#building
So download ant, and run ant in the directory that you have it stored in. Make sure to use the commandline to launch ant in order to make sure everything is working correctly.
Initially execute getPlugins.bat/sh, then:
Use update.bat/sh according to it's instructions
Or
Click on: Main Menu | Build | IntelliJ IDEA CE build
Copy content of intellij-community\out\deploy (lib, plugins folder) into existing IJ installation (sometimes it is better to delete existing folders if they contain older dependencies or when the installation was of Ultimate version)
I just start learning the Intellij. I create a small project and create several java files in a module. There is one thing bothers me, that Intellij always do a "make", which takes about 6-8 seconds, every time before run or debug the java code, no matter if I changed the code or not. I have turned on the "make project automatically" setting in compiler setting. Anyone have a idea?
Take a look at http://devnet.jetbrains.com/docs/DOC-192
One of the things mentioned at the very top is about antivirus tools:
Example : Configuring McAfee OAS
Most antiviruses allow specifying folders which are excluded from on-access scan.
For example, on my system with McAfee Enterprise, I found out a folder (c:\Dev) that was excluded by the OAS (On Access Scanner):
Moving both the installation folder, as well as the Intellij system folder (c:\Users\$user\.IntelliJIdea12) into that folder resulted in a appreciable improvement in IntelliJ performance.
Symlinking instead of moving!
If you already have IntelliJ installed then the least disruptive way of doing it is creating Symlinks. For example, for the IntelliJ system folder you would do the following:
Move c:\Users\$user\.IntelliJIdea12 to c:\dev\.IntelliJIdea12
Symlink : mklink /J c:\Users\$user\.IntelliJIdea12 c:\dev\.IntelliJIdea12
Do the same for the IntelliJ installation folder.
In my specific case, I was having an issues with large Maven Projects in IntelliJ. This is what worked for me : Tips for Handling large projects with Maven and IntelliJ IDEA
To be considered as "temp" answer, because the solution is not optimal. I really don't want to disable such whole "System Watcher" function of Kaspersky.
After consulting other threads, it seems that it's because of my Kaspersky System Watcher is slowing down the process. After turnning off the "System Watcher", the "make" finish in half a second. I wonder what "suspicious" activity in Intellij stimulate the "System Watcher".
I want to allocate around 1GB of heap size, but I can't seem to figure it out.
How to do this?
Use Help | Edit Custom VM Options…
An editor will open automatically for the right .vmoptions file, adjust the value of -Xmx, save and restart IntelliJ IDEA:
Check these documents from IntelliJ IDEA knowledge base for more details:
Configuring JVM options and platform properties
The JVM could not be started. The main method may have thrown an exception.
Answers below suggest to edit .vmoptions file directly inside the application installation directory. Please note that it's not recommended since it will cause conflicts during patch updates. The method above creates a copy of the file in the CONFIG directory and your IDE installation remains intact.
Also be aware of the 32-bit address space limit on Windows which makes it hard to use heap sizes higher than 750m. Should you need to use larger heap, make sure to switch to the 64-bit JVM first, otherwise IDE may crash on start or start to crash randomly during work.
go to that path "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1.4\bin\idea.exe.vmoptions"
and change size to -Xmx512m
-Xms128m
-Xmx512m
-XX:MaxPermSize=250m
-XX:ReservedCodeCacheSize=64m
-XX:+UseCodeCacheFlushing
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
hope its will work
For 64-bit Windows, make sure to run idea in 64 bit mode(idea64.exe) and change settings in "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 15.0.1\bin\idea64.exe.vmoptions" file.
These settings works fine for me
-Xms512m
-Xmx2024m
-XX:MaxPermSize=700m
-XX:ReservedCodeCacheSize=480m
For developers who use Ubuntu, following will help to increase heap size in InteliJ Idea. Following versions are used by myself at the moment.
Ubuntu 16.04 LTS (64 bit)
InteliJ IDEA 2016.3.4
Go to the location where the IDE is installed and find the following file. (In my case it as follows)
/home/abcde/Softwares/idea-IU-163.12024.16/bin
Then select the idea64.vmoptions file and edit it.
Remove default configuration and paste the below mentioned.
-Xms512m
-Xmx2024m
-XX:MaxPermSize=700m
-XX:ReservedCodeCacheSize=480m
Now restart the IDE and changes should reflect the IDE environment.
Worked for me to overcome Java heap size related issues.
If you use JetBrains Toolbox, then memory changes must be set inside it:
Go to the app settings in the toolbox list
Change Memory heap size option within Configuration section
Otherwise all the changes in the IDE itself or inside vmoptions file just don't apply.
In addition to what others have added, should the error persist try this
basically put what you want(as others have pointed out) in your run-config's vm options and apply
You can easily increase memory heap from IntelliJ IDEA version 2019.2 by using IDE main menu Help | Change Memory Settings.
Please check this document for details: https://www.jetbrains.com/help/idea/increasing-memory-heap.html
Make sure you check your environment variables also. Mine was not updating until I changed my _JAVA_OPTIONS value from -Xmx512m to -Xmx2048m.
I've just installed IntelliJ on Windows 8 (and 7). I then use the 'Java Hello World' Sample as my project.
I then selected the JDK that was installed (C:\Program Files\Java\jdk1.7.0_10). Project creates successfully and I can see all the classes associated with the project etc. When I "make the project" I get the following error:
Compilation completed with 1 error and 0 warnings in 2 sec
1 error
0 warnings
java: Cannot find JDK '1.7' for module 'TEST'
No matter what I do I cannot compile any Java code under Windows8/IntelliJ
I have tried the following:
Invalidating cache.
Switching to 32bit JDK instead of 64bit
Idea64.exe instead of idea.exe
Installing 1.6 incase it was a 1.7 issue??
Changed the JAVA_HOME to point to different versions (ie currently C:\Program Files\Java\jdk1.7.0_10)
I'm lost as to why this is happening.
project structure > project > choose correct jdk
or ctrl+alt+shift+s > project> choose correct jdk
also platform settings > SDK's >and make sure 1.7 is there.
Found the root of the problem. Turns out Windows 8 under parallels shares the same Desktop as OSX. This confused IntelliJ somehow and as a result it couldn't compile properly.
In parallels by removing the "Desktop" shared under Configure this then resolves the issue.
In case you want to still share the documents & desktop, the solution is to modify the idea.properties file (for instance, under C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1\bin\idea.properties ), and change the following properties to point to different a location that is specific to the OS in which you are working:
idea.config.path=
idea.system.path=
idea.plugins.path=
idea.log.path=
I also copied the previous folder (on my computer it was under
\\psf\Home\.IntelliJIdea12
) to the new location to preserve all settings.
Update: I had the same problem after I installed IntelliJ Idea 13. I moved the .IntelliJIdea13 folder to c:\Users\costa from \\psf\Home, then I modified the C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.0\bin\idea.properties file:
idea.config.path=C:/Users/costa/.IntelliJIdea13/config
idea.system.path=C:/Users/costa/.IntelliJIdea13/system
idea.plugins.path=C:/Users/costa/.IntelliJIdea13/config/plugins
idea.log.path=C:/Users/costa/.IntelliJIdea13/system/log
I made the error while editing idea.properties to leave a whitespace at the end of my personally added idea.config.path=../.IdeaIC/config line.
This resulted exactly in the Cannot find JDK '...' for module error message.
I needed to "trim" the line manually, just deleted the whitespace, restarted IntelliJ and everything worked fine again.
I found this while scanning the idea.log file where I found java.io.FileNotFoundException: C:\Software\IntelliJ IDEA Community Edition 14.1.3\.IdeaIC\config \tasks\root.contexts.zip
In my case, Idea said "Failed to save settings" (probably due to a lot of projects being open. After that, it could not run tests with "Cannot find JDK '1.8' for module XXX" message. Idea restart solved the issue for me.
I believe this is an IntelliJ bug.
This isn't a fix, but you can work around this by going to Settings > Compiler, and disabling 'Use External Build'.
It seems that sometimes Intellij (or the user:-)) is getting confused when importing settings, especially if you change the paths where the jdk resides (for me it happened during a migration to a new Linux environment).
The only way I could correct this was to delete the user's settings folder.
In Linux :
I removed the folder (and subfolders): ~/.IntelliJIdea12/
Of course this would remove the saved settings, licenses e.t.c.
We bundle the Java 6 JRE with our application installer so that it can be run on any machine, but this makes the application a little bit heavier. So we are planning to reduce the size of the JRE. If anyone has done this sort of task, can you please provide guidance to move forward with this?
Look at the README file in the JRE directory. The 'Optional Files and Directories' section lists a number of files that can be removed from the Oracle/Sun JRE if you are packaging it with your application.
I use an Ant buildfile to copy the JRE from the system install location to the package directory when creating an installation. Put the list of files you want excluded in a separate file and use the 'excludesfile' attribute to load this list:
<copy todir="${deployed_jre_dir}">
<fileset dir="${system_jre_dir}" excludesfile="jre_excludes.properties"
</copy>
Sample jre_excludes.properties file:
# per the README from the JRE, these files are for the browser plugin and are not needed otherwise
#bin/javaw.exe
bin/javaws.exe
bin/javacpl.exe
bin/jucheck.exe
bin/jusched.exe
bin/wsdetect.dll
bin/NPJPI*.dll
bin/NPJava*
bin/NPOJI610.dll
bin/RegUtils.dll
bin/axbridge.dll
bin/deploy.dll
bin/jpicom.dll
bin/javacpl.cpl
bin/jpiexp.dll
bin/jpinscp.dll
bin/jpioji.dll
bin/jpishare.dll
lib/deploy.jar
lib/plugin.jar
lib/javaws.jar
lib/javaws/messages*
lib/javaws/miniSplash.jpg
bin/new_plugin**
bin/jureg*
bin/ssv*
bin/jqs*
bin/jp2*
lib/deploy/**/*
# if you do not need any RMI stuff
# wildcard to catch .exe files on Windows
# note rmi.dll is not excluded, which is needed by jconsole; add rmi.dll if you do not need jsonsole
bin/jbroker*
bin/java-rmi*
bin/rmid*
bin/rmiregistry*
bin/tnameserv*
bin/orbd*
bin/servertool*
# do not include QuickTime
# this will be in the jre dir for machines that have QT installed
lib/ext/QTJava.zip
Some update info: since java 8 there is an official Oracle tool called jrecreate for creating of small embedded JRE packages.
For my Java 8 Update 144 desktop application I exclude the 2 big Java FX files:
bin/jfxwebkit.dll // ~34 MB unpacked
lib/ext/jfxrt.jar // ~17 MB unpacked
The zipped jre is 49 MB instead of 66 MB.
For me this is an acceptable tradeoff between reduced size and added build complexity (and potential bugs).
You're trying to reduce a standard JRE's size? Don't do that. You can choose to bundle an alternative JRE which might be smaller. A list can be found on this Wikipedia page. As always, beware of compatibility issues and test your application thoroughly.
An other, and safer, way is to just require an installation of a JRE on the target machine.
You can use jlink tool to post-process JDK and create a smaller image by keeping only a specified set of JMPS modules and debug information. This is a common practice right now as we are using more containerized environments.