IntelliJ memory issues - intellij-idea

I have been using IntelliJ IDEA 12 for developing a Java Applications. I have the best experience for an IDE. It was working fine until recently. It started to show the heap size memory issue recommending to increase the Xmx and ask me to ignore or shutdown. The behaviour is weird as the IDE starts at 300 MB then it starts to take more memory until it reaches 750+ MB that's when it shows the problem.
I switched back to eclipse and the memory foot print is stable at 300 MB and doesn't increase by time like IntelliJ
Is IntelliJ doing some background process related to my code causing this increase? or is it a memory leakage problem with the IDE?

I've used IDEA for 10 years (and used IDEA 12 for a year before switching to IDEA 13 EAP builds) and have never had a memory issue. And I do not see any consistent mention of memory issues in the IDEA forums.
That said, a memory leak was just fixed (as in released today) in the IDEA 13 EAP. The VcsLogGraphTable class had a leak. The ticket does not give any indication if the leak was/is present in IDEA 12. Based on the name of the class, it should only come into play for Git or Hg graphs (but Hg graphs were added in 13). Based on my experience with how they do tickets, I interpret this as an IDEA 13 issue.
First, make sure you are using the latest version 12.1.6.
Often times memory issues are a result of a poorly written third party plug-in. You can try to disable any third party plug-ins and see if the issue is resolved.
The other thing you can do is follow the instructions in the document How to report IntelliJ IDEA performance problems and take CPU snapshots and report the issue to JetBrains. That way they can confirm a leak in IDEA 12, or tell you what plug-in is the culprit.

Related

Why does Intellij not release memory after closing a project?

I had three projects open. One of them - Spark - was very large. Upon closing spark there was NO difference in memory usage - as reported by os/x activity monitor. Note: all projects are opened within the same Intellij instance.
It is in fact using just over 4GB. And I only now have two projects open. Those two projects only take up 1.5GB if I shut down Intellij and start it up again.
So .. what to do to "encourage" Intellij to release the memory it is using? It is running very very slowly (can not keep up with my typing for example)
Update I just closed the larger of the two remaining projects. STILL no reduction in memory usage. The remaining project is a single python file. So Intellij should be using under 512Meg at this point!
Following up on #PeterGromov's answer it seems that is were difficult to obtain the memory back. In addition #KevinKrumwiede mentioned the XX:MaxHeapFreeRatio which appears to be an avenue.
Here are a couple of those ideas taken bit farther from Does GC release back memory to OS?
The HotSpot JVM does release memory back to the OS, but does so
reluctantly.
You can make it more aggressive by setting -XX:GCTimeRatio=19
-XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=30 which will allow it to spend more CPU time on collecting and constrain the amount of
allocated-but-unused heap memory after a GC cycle.
Additionally with Java 9 -XX:-ShrinkHeapInSteps option can be be used
to apply the shrinking caused by the previous two options more
aggressively. Relevant OpenJDK bug.
Do note that shrinking ability and behavior depends on the chosen
garbage collector. For example G1 only gained the ability to yield
back unused chunks in the middle of the heap with jdk8u20.
So if heap shrinking is needed it should be tested for a particular
JVM version and GC configuration.
and from How to free memory in Java?
To extend upon the answer and comment by Yiannis Xanthopoulos and Hot
Licks (sorry, I cannot comment yet!), you can set VM options like this
example:
-XX:+UseG1GC -XX:MinHeapFreeRatio=15 -XX:MaxHeapFreeRatio=30 In my jdk 7 this will then release unused VM memory if more than 30% of the heap
becomes free after GC when the VM is idle. You will probably need to
tune these parameters.
While I didn't see it emphasized in the link below, note that some
garbage collectors may not obey these parameters and by default java
may pick one of these for you, should you happen to have more than one
core (hence the UseG1GC argument above).
I am going to add the -XX:MaxHeapFreeRatio to IJ and report back if it were to help.
Our application presently only runs on Java7 so the first approach above is not yet viable - but there is hope since our app is moving to jdk8 soon.
https://www.jetbrains.com/help/idea/status-bar.html
I used this:
Shows the current heap level and memory usage. Visibility of this section in the Status bar is defined by the Show memory indicator check box in the Appearance page of the Settings/Preferences dialog. It is not shown by default.
Click the memory indicator to run the garbage collector.
The underlying Java virtual machine supports only growing of its heap. So even if after closing all projects the IDE doesn't need all of it, it's still allocated and counted as used in the OS.

Intellij IDEA 2016.2 high CPU usage

I have only one project (an ordinary SpringFramework project) opened. And the IDE is crazy using CPU:
JVisualVM CPU sample:
Note this happened just recently
Any idea?
The correct answer was posted by #matt-helliwell if you're coming from a version older than 2016.2.
File -> Invalidate Caches and Restart
If the above doesn't fix your problem, track this issue:
https://youtrack.jetbrains.com/issue/IDEA-157837
I invalidated the caches and it solved the problem for some time. But after a couple days Idea (my version is 2017.1.3) started to work slow with some freezing delays again. Finally I increased maximum available memory to 2 Gb (parameter -Xmx in idea.exe.vmoptions/idea64.exe.vmoptions file) and now it works perfect
I solved the problem by running idea64 bits :
JetBrains\IntelliJ IDEA 2016.2.4\bin\idea64.exe
Another possible solution, my IDEA was very slow because of a huge sql file open which was consuming all my CPU.
It took me a long time to notice this was happening only when opening a specific utility class with more than 1000 lines of code.
This class had maybe 50 public static methods (the reason why it is a utility class...), all pure.
At first, I thought it was stuck on a loop of "Performing code analysis" because that was the thing running heavily on the background as shown when hovering the mouse above a green check on top of the window of the offending class:
, but in reality, it was slowly scanning each instance in which the code was being executed in the entire source code.
It took like 45 minutes to scan the entirety of the class, the entire time the CPU usage at max (100%).
Once the class is closed the usage stops.
The issue (at least with AS Dolphin 2022-23) is that the analysis is never memorized, so if the window is closed, and opened later, the analysis begins from 0. So, it never gets cached...

IntelliJ IDEA 12.1 eat 100% CPU from time to time

I've just updated my IntelliJ IDEA to latest 12.1 version and I found my laptop CPU usage become 100% from time to time, monitor the progress manager I found IDEA fork an new Java process regularly and it runs for several tens of seconds and shutdown. During that time the CPU usage is close to 100%:
Chances are the external build mentionned by #CrazyCoder compiles your project automatically when you make changes to your source files. If it annoys you too much, you can disable automatic compilation in File > Settings > Compiler > Make project automatically (uncheck the box).
I had the IDEA 12 process itself (not a forked Java) occupy 100%, and respond very slowly to keypresses, navigation, etc.
Eventually I resolved this by cleaning out the cache, prefs, Application Support dir, etc and uninstalling/reinstalling IDEA 12. You have to reinstate your preferences and let Idea reindex your projects (due to removing its cache) - but this shouldn't take long.
Here's a list of some places to clean on OS X (slightly out of date for IDEA 12, but a useful starting point).
I am using IntelliJ 13 Community Edition and have found this problem on Linux.
It my case it is the Intelli JBehave plugin causing these issues.
When opening a dialog the CPU usage of the Java process drops right back to 5 to 10% percent.
When disabling the plugin the same is true.
Goto Home Folder then Navigate to .IntelliJIdea13\config\options
Edit the file "project.default.xml" Change the VM_PARAMETERS Xmx and Xms as follows
It decreased the CPU usage to 50%

How to improve IntelliJ code editor speed?

I am using IntelliJ (Community Edition) for several months, and at first I'm pleased about its speed & simplicity. But now, after upgrading to version 10, it's extremely slow. Sometimes I click a file then it takes 5 - 15 seconds to open that file (it freeze for that time).
I don't know if I have done anything which cause that: I have installed 2 plugins(regex, sql), and have 2 versions of IntelliJ on my machine (now the version 9 removed, only version 10 remains).
Is there any tips to improve speed of code editor, in general, or specifically IntelliJ? I have some experience when using IntelliJ:
Should open IntelliJ a while before working, cause it needs time for indexing.
Don't open too many code tabs
Open as less other program as possible. I'm using 2 GB RAM WinXP, and it just seems fairly enough for Java, IntelliJ & Chrome at the same time.
Try to increase using memory size at %IDEA_HOME%\bin\idea.exe.vmoptions
-Xms128m
-Xmx512m
-XX:MaxPermSize=250m
Xms128m means that at startup there will be allocated 128 mb for heap.
Xmx512m means that maximum heap size available for IDEA is 512 mb
-XX:MaxPermSize=250m PermGen related to java heap.
Also you can set maximum garbage collector pause
-XX:MaxGCPauseMillis=10
That means that java's GC will take max 10ms to do his work.
And use concurrent Mark-Sweep (CMS) Collector (But i'm not sure that this will help for latest version of IDEA)
-XX:+UseConcMarkSweepGC
You should submit a CPU performance snapshot to the issue tracker as described in the FAQ.

Netbeans and Glassfish performance

I was wondering if anyone had any performance options that might work for me. I am using Netbeans 6.1 and Glassfish V2 on my work laptop and the memory requirements are getting a little tiresome. I have 3 gb of ram and I frequently have to kill everything and restart it due to PermGen Space errors.
I've played with the mem sizes as well but nothing seems to really help.
Is there a way for you to monitor glassfish through JConsole? JConsole will show you how much PermGen space (as well as other spaces) is being used. Using this information can help you tweak your startup parameters.
This page http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp lists a few and I know I've seen more, esp. when it comes to setting permgen sizes.
You might also want to look at how your webapp(s) are allocating things that go into permgen space. Maybe the problem is there rather than in NB/GF combo.
Finally, is it possible for you to upgrade to NB 6.7? I know it's difficult to change your app server for development, esp. if you deploy to that version of the app server in production (I've experience problems there too). But changing the IDE could help too.
I know this is not an "answer", but I hope it helps.