I ram running into issue where my application throws PermGen size error whenever I generate cobertura report using this command clean cobertura:cobertura. I have the tried almost everything such as the following:
Increase permgen size in sts.ini
Increase permgen size in jdk vm argumemts by going into Windows -> Preferences
-> Java -> Installed JREs -> click jdk -> edit and on the vm args
Increase permgen size in maven.bat file
Some in stackOverFlow recommended to mention the version in surefire plugin and I have that in place already
None of the above is helping me at all. I am using Mock/PowerMock objects a lot in my JUnit test cases. Maven test runs perfectly fine.
How can I fix this issue?
Thanks
Since you tried to change sts.ini, I'm assuming you are running it from inside STS. Even when Maven is kicked off by STS, it runs in a separate process from STS, so changing sts.ini wouldn't help. you need to set the MAVEN_OPTS with the increased permgen size in the run configuration for the mvn job.
set MAVEN_OPTS.
Value will be: -Xms1024m -Xmx3000m -XX:MaxPermSize=1024m
export MAVEN_OPTS="-Xms1024m -Xmx3000m -XX:MaxPermSize=1024m" //unix
set MAVEN_OPTS="-Xms1024m -Xmx3000m -XX:MaxPermSize=1024m" //window
Related
RESOLVED check below for solution.
I'm using Intellij Idea 2017.2.2. Below is my intellij Specs.
My Intellij would only occasionally fail a maven build or a jboss server start with the error
Error occurred during initialization of VM
Could not reserve enough space for 1048576KB object heap
If I were to run the maven build with the vm args of
-Xms512m -Xmx1024m
The build would fail 9 out of 10 times (not exactly every 10th, but just randomly). But on the 10th time it would work. I simply have to keep pressing the install button until it works.
This was a major problem before was that if I don't specify the vm args then the build would go about halfway then fail on running out of java heap space.
The same exact behavior can be observed for my jboss server (JBOSS6.4 - 7.5.0.Final redhat 21), where the server would fail to start 9 out of 10 times. Then start up as randomly as it does not.
Specs
IntelliJ IDEA 2017.2.2
Build #IU-172.3757.52, built on August 14, 2017
Licensed to -----
Subscription is active until May 31, 2018
JRE: 1.8.0_152-release-915-b10 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 7 6.1
What I tested
I upgraded from Intellij 2017.1 to 2017.2 and the behavior did not change.
I also tried to do the same on Eclipse which also did not help.
Clean restart of PC, then close all the unnecessary apps, open intellij do a maven build and yet it fails, but a few more clicks and it works inconsistently as usual. (note at this moment only 6gb out of 16 is used, there is no way there is an insufficiency with memory)
*Edits
This PC have 16 gb of ram. While the fails are happening about 9.5GBs are being used at that moment.
Ultimately I was able to resolve the issue by updating the proper JDK.
My project was picking up on an incorrect JDK and hence was running the 32 Bit as opposed to 64 bit JDK.
Simply added the correct JDK under File > Project Settings.
It seemed that my project never required that much memory before, but once the need had risen, it seems that a 64 bit became required.
I have solved this problem by changing the build settings in Intellij.
Please follow the below steps.
For SBT:
1. Go to File -> Settings -> Build, Execution Deployment -> sbt
2. Change the value of Maximum heap size, MB to your available memory. Ex. 512
(Previously this value was 1536, due to this I faced the problem)
For Maven:
1. Go to File -> Settings -> Build, Execution Deployment -> Maven -> Importing
Change the value of VM options for importer to your available memory. Ex. -Xmx512m
I had to do the following options to get it pass the error.
Spec used: IDEA IntelliJ 2019.3.5 (Community Edition)
Increase the memory in IntelliJ VM Options
Step 1:
Go to Help -> Edit Custom VM Options
Step2: Change the Heap sizes as given below
Run the app with increased memory by setting the VM options
Run -> Edit Configurations
My issue was resolved by installing Visual C++ Redistributable Packages:
https://aka.ms/vs/16/release/vc_redist.x64.exe
I have imported a SBT project into IntelliJ(version 14). When I am trying to run something in the terminal, the console output is giving me "java.lang.OutOfMemoryError: Java heap space".
I have tried increasing the size (Xms2048m, Xmx2048m) in *.vmoptions, and also in the IDE build settings of SBT project. I have restarted my machine as well. Nothing is working out.
Any more inputs on it other than the things I have tried ?
P.S: I am running the project through the activator. When I am doing it from IntelliJ command prompt it's throwing me the error, but when I run the activator from windows command prompt, it is successfully running the application.
You just asked your IDE:
-Xms2048m - ask VM to allocate 2048MB (2GB) heap on start
-Xmx2048m - limit heap to 2048MB
The reason could be:
You tried to exceed 2048MB
Allocating 2048MB on start was not possible (you probably just went out of RAM)
System thought so fast allocation was a malware.
I think you will need to provide the memory settings as parameters to the command you are running on the console.
To the best of my knowledge any parameters set inside IntelliJ will only be for use of IntelliJ itself, and when you run the project from the SBT window (I am assuming it works like the maven window).
Also as far as I know the terminal window in IntelliJ is just a "pass through" to the underlying console of the host system.
Not sure you need it, but this seems to be a good explanation of the memory settings, and links to duplicate answers: What are the Xms and Xmx parameters when starting JVMs?
I was getting a similar issue while building the project in IntelliJ what worked for me is to update the build memory size in settings as below:
Settings (or Preferences) -> Build, Execution, Deployment -> Compiler -> Shared build process heap size (Mbytes)
I am building a maven project, since last 1.5 yrs build was working fine but now I am getting the PermGen space error.
[ERROR] Internal error: java.lang.RuntimeException: org.jfrog.build.extractor.maven.BuildInfoRecorder.sessionEnded() listener has failed: java.io.IOException: Remote call on channel failed: PermGen space -> [Help 1]
[ERROR] org.jfrog.build.extractor.maven.BuildInfoRecorder.sessionEnded() listener has failed:
java.lang.OutOfMemoryError: PermGen space
I have tried below options in order to resolve it:-
1) Under Manage Jenkins, then Configure System. In the Global properties section, added Environment Variables called MAVEN_OPTS with the value set as -Xmx200m -XX:MaxPermSize=512m
2) Under job configuration, then Build, in the MAVEN_OPTS, added below properties:-
-DXms512m
-DXmx1024m
-DXX:PermSize=512m
-DXX:MaxPermSize=1024m
-DXX:+CMSClassUnloadingEnabled
-DXX:+UseConcMarkSweepGC
Still the error is occurring.
Note:- Error is not permanent, it goes away after few builds but again start appearing and then again goes away after several retries.
Thanks.
Maybe I'm wrong, but it seems that your memory error happens when Jenkins try to send the build information to Artifactory (with a post step action).
Did you upgrade the Jenkins Artifactory plugin recently?
Can you try do disable the "Capture and publish build info" option?
And last option, can you try update the JENKINS_JAVA_OPTIONS (in the jenkins service config file) to increase the MaxPermSize?
## Type: string
## Default: "-Djava.awt.headless=true"
## ServiceRestart: jenkins
#
# Options to pass to java when running Jenkins.
#
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Xms2G -Xmx4G -XX:MaxPermSize=256m"
As Maven project deploys artifacts not during build step on a node, but on the master, I suspect Permgen problem could by resolved by either upgrading Jenkins core, plugins or by increasing Permgen max size in Jenkins startup options.
ps. Java 8 obsoletes Permgen.
maybe I am blind and you have written it somewhere but when I have faced a similar issue, then I have upgraded the JRE version for Jenkins itself from 7 to 8. The problem started, when I have used Jenkins 2.X and Java 7.
Best regards,
Max
on centos6 install jenkins by rpm or yum
vim /etc/sysconfig/jenkins
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Xmx1024m -XX:MaxPermSize=512m"
Now that OSX Maverick works with memory different (so it seems and from what I've read), when I run Java as a separate JVM (Ant/JUnit/etc.), I often get OutOfMemory exceptions as it bases the max heap on memory available which is usually close to zero (because that's apparently how Maverick works?). I know I can set the max heap space using the -Xmx argument for a run or external tool configuration in Eclipse, but that is a pain when I have several possible configurations that can be run.
I believe I would have to run in a separate JVM so my configurations don't get polluted with Eclipse classpath JARs and to a smaller extent, so the Eclipse JVM doesn't get polluted with configuration runs and all the class loading that goes on.
Is there a global setting to set the max heap available for all JVMs launched by Eclipse? For Ant, I tried setting ANT_OPTS in my environement to "-Xm1024m", but that setting doesn't seem to take when running Ant through Eclipse. If I run Ant from the command line directly, it does seem to work (or at least I didn't get an exception). When running Ant in verbose+debug mode in Eclipse, I do see "Setting project property: env.ANT_OPTS -> -Xmx1024m" so I know the variable is set.
I ran Java VisualVM to get a better idea what is going on, this is what it has:
JVM: Java HotSpot(TM) 64-Bit Server VM (23.25-b01, mixed mode)
Java: version 1.7.0_25, vendor Oracle Corporation
Java Home: /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre
JVM Flags: <none>
Main class: org.eclipse.ant.internal.launching.remote.InternalAntRunner
You can configure JVM arguments for an Eclipse Ant build in the Run > External Tools > External Tools Configurations dialog in the JRE tab.
Note that the default is actually to run Ant in the same JVM as Eclipse (which makes some additional Eclipse tasks available).
Running VisualVM made me realize Eclipse was still using 1.7.0_25 and not 1.7.0_45 which is the latest I have installed. Once I updated Eclipse to use 1.7.0_45, I no longer have the issue as the VM does indeed use 1/4 of total memory. Would be nice to know for sure, but it seems like build 25 had a bug or something.
I just upgraded to IntelliJ IDEA 12.0 and get an error immediately upon attempting to launch:
The JVM could not be started. The maximum heap size (-Xmx) might be too large or
an antivirus or firewall tool could block the execution.
I checked my idea.exe.vmoptions file and the maximum heap size is only 640m (I have 8 GB physical memory and am not running any other applications).
idea.exe.vmoptions
-Xms128m
-Xmx640m
-XX:MaxPermSize=640m
-XX:ReservedCodeCacheSize=64m
-XX:+UseCodeCacheFlushing
-ea
-Dsun.io.useCanonCaches=false
I still have IntelliJ IDEA 11.4 on my machine and I am able to run that (using the same values for max heapsize in idea.exe.vmoptions). Since IntelliJ IDEA 11.4 runs, I don't believe it is an antivirus or firewall issue. I have also checked those settings as well.
Anyone run across this or have any idea (no pun intended)?
Please see this answer for the problem background and the solution.
Your questions seems to be the exact duplicate of:
How to increase intellij 32bit xmx more than 1GB?
Assuming you are on windows I am curious why you are running the 32bit version of intellij when you have a 64bit machine?
I was having the same error and found that there was two things going on. The first was that the link I had in the taskbar was pointing to the idea.exe instead of the idea64.exe, which meant I was only launching the 32bit version of intelliJ.
Second there is another file for vm options for the 64bit. idea64.exe.vmoptions
After switching to the 64bit exe and making sure the vm options I wanted were correct in the vmoptions file I did not have any further issues.
On another interesting note I found that on 32bit machines when the 32bit version of intelliJ was set to have 1gb of memory for -Xmx and I had chrome open I would get the error. If I closed chrome I would no longer get the error. I think this had something to do with the jvm verifying that the required amount of memory was available before launching.
Try to configure your idea to the default values
-Xms128m
-Xmx512m
-XX:MaxPermSize=250m
-XX:ReservedCodeCacheSize=64m
-XX:+UseCodeCacheFlushing
-ea
-Dsun.io.useCanonCaches=false
VM options are loaded from the IDE_HOME\bin\[bits][.exe].vmoptions file.
More info: https://intellij-support.jetbrains.com/entries/23393413-The-JVM-could-not-be-started-The-main-method-may-have-thrown-an-exception
I found that switching from a 32-bit version to a 64-bit version caused the issue, as my windows shortcuts still pointed to the old idea.exe and not the correct idea64.exe.