I'm getting Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
when running some main object in scala with IntelliJ Idea,
with the "^R" shortcut or Right click-> run 'mainObjName'
This program runs without problem if using sbt:
$ JAVA_OPTS="-Xmx4096m" sbt
sbt:prj> run mainobj
With the search results got from this site, I tried to set the heap space to 4096m in :
1.Preferences->Build Tools->sbt->Maximum heap size,MB
2.Preferences->Compiler->Build process heap size(Mbytes)
3.Preferences->Compiler->Scala Compiler->Scala Compiler Server->JVM Maximum heap size,MB
4.Preferences->Build Tools->Maven->Runner->VM Options (with -Xmx4096m)
But none of these works.
I'm running a memory hungry program, and this is clearly not a build time error but some thing happened during runtime.
So, How to change the maximum heap size for running a program in IntelliJ Idea?
btw, the program runs fine on linux workstation with much more memory, but seems the default heap size configuration is the same on the IntelliJ Idea on MacOS vs Linux. seems java consumes more memory on MacOS?
It seems, that all the options you've tried are setting the memory for various compiler facilities.
You could try to change the memory available for the runtime by setting the VM options to -Xmx4096m in the configuration you are running. You can find the configuration with your mainObjName under Run -> Edit Configurations... -> Application
Related
When I run the program from PyDev/Eclipse, it runs out of memory and gives the following error:
java.lang.OutOfMemoryError: java.lang.OutOfMemoryError: GC overhead
limit exceeded
It goes away when I pass the -J-Xmx2048 limit from the command line. So clearly, this can be solved if PyDev can read these somehow.
In Eclipse, I tried setting this values in the run options (in eclipse) as program & vm arugments, but I get the same error. I also tried setting the JAVA_MEM option, but that doesn't help either.
Any ideas how I can instruct PyDev/Eclipse to read these arguments?
It turns out that the Run As -> Run Configurations -> Arguments -> Vm Arguments for Jython also expect Java arguments and not Jython ones :/
Setting the VM arguments to -Xmx2048 fixed the issue. The memory usage for java now peaks to 2G (earlier 1G) confirming the fix.
In my eclipse, while running a mapreduce program, it is throwing Out of memory exception
I tryied with changing the parameters in eclipse.ini (-Xms40m
-Xmx768m values to -Xms4000m
-Xmx7680m) but still getting the same error.
What would be the solution for this.
The eclipse.ini setting only sets the heap for Eclipse itself.
For a program you run from Eclipse look at the Run Configuration for the program and set the -Xmx value in the VM arguments.
I was trying to parse the 11GB heap dump using Eclipse MAT and I am getting the following error
An internal error occurred during: "Parsing heap dump"
I think the MAT is unable to parse such a huge heap dump. I read some posts and increase the VM configurations to more than 80% of the dump size. Following are my vm configurations
-vmargs -Xms8192m -Xmx10240m
and I am still not able to load the dump. I tried with ParseHeapDump.bat with no changes ...
Keep increasing Xmx till the JVM complains, then increase your swap file size, then increase Xmx again, etc.
At that stage it will take ages because it will be using disk as RAM.
I recently installed Eclipse MAT (Eclipse Memory Analyzer Version 1.9.1) on Mac OS Catalina (10.15.3). I needed to review a 4g heap dump. The default JVM heap size for MAT is 1024m.
I think the easiest way to increase the JVM's heap size is to use a shell window - go to the /Applications/mat.app/Contents/Eclipse/ folder. Then vi MemoryAnalyzer.ini and change -Xmx1024m to your required value, in my case I went with -Xmx10g.
To review the change, restart MAT and go to the help -> About Eclipse Memory Analyzer then click installation details, and look for the entry: eclipse.vmargs=-Xmx10g about 50 lines down.
This setup worked for me.
I also recently installed Eclipse MAT to analyze a 4.85GB heap dump file.
Eclipse Memory Analyzer Version: 1.11.0
MacOS Catalina: 10.15.7
Hardware Memory: 16GB
Heap dump file size: 4.85GB
Heap dump file type: PHD
Classes: 33.6k
Objects: 4.8m
Class Loader: 575
I changed the MemoryAnalyzer.ini to 14GB as follows:
-vmargs
-Xmx14g
I also confirmed the configuration as follows:
Help -> About Eclipse Memory Analyzer 1.11.0
Clicked on Installation Details
Clicked on Configuration tab
Looked for eclipse.vmargs=-Xmx14g.
It took some minutes to load this 4.85 heap dump file.
Note: I unsuccessfully tried Xmx setup with 2g, 4g, 8g, 10g, 12g - all failed with JVM out-of-memory in the Eclipse MAT tool.
On the Windows install of Eclipse Photon, I got around the problem by updating the memory parameters in the eclipse.ini file. This was directly under my c:\eclipse folder.
-Xms6g
-Xmx6g
I tried setting it to 4 gigs for a memory dump that was about 4.1GB and it failed. So, the rule of thumb is to set it to a higher value than the size of the memory dump.
I created a simple console application that I run from Eclipse (right clicking on the file and selecting run as Java application.) I stuck a sleep in there so I can ensure that the process is still running when I start the Aquire Heap Dump Dialog. I start the dialog, hit refresh, and there are no local processes listed.
I checked Eclipse's error log and it only reports that it had problems listing the IBM VM processes (the HPROF one is configured and working fine.)
What am I doing wrong?
Why not create the heap dump from your program code?
https://blogs.oracle.com/sundararajan/entry/programmatically_dumping_heap_from_java
Or when that runs into security issues from here:
create heap dump from within application, without HotSpotDiagnosticMXBean
I used that to take a heap dump after a fixed number of iterations in my JUnit tests, all that is left to do is open the dumps in Eclipse MAT and find the cause of the memory leak :-(
I faced same issue and after googled I found this solution.
Specify jdk path in "Acquire Head Dump" -> "Configure..." -> Select "HPROF jmap dump provider" -> "-jdkhome" -> speficy jdk path by default it should be
"C:\Program Files\Java\jdk1.8.0_102" or your jdk location.
I hope it works for you.
I cannot get JBoss Portal to start from Eclipse, though the AS alone starts fine, and the Portal starts correctly as well, when started from the command line as opposed to from within Eclipse. I'm running in Windows, with 3GB. Suggestions? Thank you.
I've spend hours to discover this, and almost gave up and started to use JBoss out of Eclipse.
In order to increase your JBoss vmargs when starting it from Eclipse you have to change JBoss launch configuration. If you change standalone.conf, nothing happens because Eclipse doesn't use it.
So, to change JBoss vmargs in Eclipse, you have to go to "Servers" tab, right click on your Jboss instance, and select "Open".
It will appear a new window. In the first section, you have a option: "Open launch configuration". When you click there, you'll see the textbox to change vmargs.
Hope this helps you!
There are different types of OutOfMemory errors:
java.lang.OutOfMemoryError: Java heap space
Increase the -Xms and -Xmx. I'd make sure they are set at least 256m and generally it's a good idea to set them to the same value.
java.lang.OutOfMemoryError: PermGen space
Add either -XX:+CMSPermGenSweepingEnabled or increase the PermGen size: -XX:PermSize=256m
java.lang.OutOfMemoryError: GC overhead limit exceeded
Add more heap, the garbage collector can't free enough memory with each cycle. Also try turning on GC logging.
java.lang.OutOfMemoryError: unable to create new native thread
Decrease your heap :) This means that you have too much memory allocated to the heap that the OS doesn't have enough memory to create threads..
Two last things, the above can be configured in jboss/bin/run.conf.
Also when starting JBoss see what -X parameters are being passed to the JVM, it prints this information by default, verify that it's what you expect it to be.
You need to increase the memory you're allocating to Java, in particular heap space and PermGen. This article is highly relevant. It mentions that this issue often occurs with Eclipse and JBoss (since both are fairly large), and provides a solution (adjusting the command-line flags).
What are you using for running portal from eclipse? Maybe Jboss tools can help you
http://www.jboss.org/tools
According to my experiments, all options of vmargs set in eclipse.ini, plays only once - when creating a new workspace. When you want to change the options in the existing workspace, use run/debug configuration as in https://stackoverflow.com/a/10814631/715269. vmargs in ini won't be read any more.
Be careful, you should set -XX:MaxPermSize=...M, not -XX:PermSize=..., the last sets minimal, starting PermSize.
ad. Jeremy. It is senseless to put mins and maxs to the same value. You deprive Eclipse of adaptability. -Xms and -Xmx ( heap) and PermGen and MaxPermGen should be different. (MaxPermGen =256 by default)