I am running jMeter from the command line on a Mac. Today it threw an Out of memory, heap space error....
newbie$ sh jmeter.sh
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
at java.awt.image.Raster.createPackedRaster(Raster.java:455)
I know I need to increase the memory allocated to it, but not sure how. I looked at this post Unable to increase heap size for JMeter on Mac OSX and found that jMeter script file in the bin folder it mentions and made the below updates..
HEAP="-Xms1024m -Xmx2048m"
NEW="-XX:NewSize=512m -XX:MaxNewSize=1024m"
But I am still getting the out of memory error. Do I just need to give it more or am I changing in the wrong place? Could it be I need to restart my whole machine?
As far as I understand:
You made changes to jmeter script
You're launching jmeter.sh script
You want to know why the changes are not applied?
If you changed jmeter script why don't you just launch it as ./jmeter ?
If you need to start JMeter via jmeter.sh for any reason, run it as follows:
JVM_ARGS="-Xms1024m -Xmx2048m -XX:NewSize=512m -XX:MaxNewSize=1024m" && export JVM_ARGS && ./jmeter.sh
See Running JMeter User Manual chapter in particular and The Ultimate JMeter Resource List in general for the relevant documentation.
If you have trouble finding it in the logs, then
You can use
ps -ef | grep jmeter
this may give you the details( Not a mac user, but I thing ps -ef would work)
The other option is to use jvisualvm, it ships already with jdk, so no extra tool is required.Run the visualvm and the jmeter, you can guess the name of the application ( entry of jemter ) on the left pane of visualvm , click on it, and all the jvm details will be available.
After this you can confirm whether jmeter is availed with 2GB max Ram. And increase if needed.
There could be different possible reasons for OutOfMemory Error. If you have successfully changed the allocated memory/heap size and still getting the issue then you can look into following factors:
Listeners: Do not use 'TreeView' and 'TableView' Listeners in actual load test as they consume lot of memory. Best practice is to save results in .JTL file, which can be later used for getting different reports.
Non-GUI Mode: Do not use GUI mode while performing actual load test. Run test from command line.
For more, visit the following blog as it has some really nice tips to solve OutOfMemory issues in JMeter.
http://www.testingdiaries.com/jmeter-out-of-memory-error/
I am using the Fortify SCA plugin with Maven 3.2.1 to scan a pretty large Java webapp.
I have a custom .bat file that sets up my all my environment variables and makes a call to mvn.bat to start the scan.
Then mvn.bat reads my pom.xml and finds the custom profiles for clean, translate, and scan and then calls sourceanalyzer.
The trouble is, it never seems like sourceanalyzer uses the full amount of memory that I grant it in either the custom bat file or the pom file. This machine has 16GB of RAM, and when the scan is done 18-20 hours later it will print "memory used: 317 MB" and the report has a bunch of Out of Memory warnings. This machine is doing nothing besides this scan, and while it's running the Task Manager shows that something is using a bunch of memory.
The error message is "Scan progress is slowing due to JVM garbage collection."
My MAVEN_OPTS:
-Xmx4096m
-XX:MaxPermSize=1024m
-Dfortify.sca.64bit=true
-Dfortify.sca.Xmx=8000m
-DskipTests=true
-Dfortify.sca.verbose=true
I need to figure out how to both speed this scan up and remove the memory warnings.
Thanks
You can try using the SCA memory variable option. Set:
SCA_VM_OPTS=-Xmx8000M
You can also try posting Fortify issues to their online forum at https://protect724.hp.com. The support group monitors those forums.
I'm currently having this problem where I am executing a query that will load large of records. At first execution, it is successful, but when I
execute again, I am having java heap size out of memory.
I Know I can increase java heap size using command line, but that requires a compiled jar file.
But I am currently on the development process, so how can I increase java heap size in that case?
Im using Elipse as my IDE.
Thanks for any response.
It doesn't require a compiled jar file. Choose Run - Run configurations... - Select your run configuration - Arguments tab. Then enter the appropriate command line argument in the VM arguments text box: -Xmx1024m for example.
You can modify the eclipse.ini file located inside of our eclipse directory .There you will find Xms40m Xmx256m parameter with some value , you can increase it to Xms256m Xmx1024m . Then check whether outofmemory error is still there . If its there then try tuning these parameter slightly increasing and check.
Apperently that was not enough for an answer... well, let me just copy the text from those answers instead :S
You can use the environment variable _JAVA_OPTIONS to set the default heap size. This will change the heap size for all Java programs. Like this:
export _JAVA_OPTIONS="-Xmx1g"
I'm trying to increase the heap size in java for weka which keeps crashing. I used the suggested line:
> java -Xmx500m -classpath
but I get the following error:
-classpath requires class path specification
I'm not sure what this means. Any suggestions?
What I found was the actual issue was in the file 'RunWeka.ini' in '\Program Files (x86)\Weka-3-6'. I opened it with notepad and in the middle of the file there is a line 'maxheap = 512m'.
I changed the line to read 'maxheap=2000m', saved the file and reloaded weka and this fixed my problems.
I'm not sure if this is the correct way to do it or not but it worked for me.
Run this command in your terminal:
java -Xmx1024m -jar weka.jar
Omit the -classpath option. Use just -Xmx500m option.
So, instead of just:
java weka.core.Instances data/soybean.arff
you do:
java -Xmx500m weka.core.Instances data/soybean.arff
If you run weka via some script (RunWeka.bat for example), then you need to modify that script (with some text editor like notepad).
If you're using Weka 3.8.1 on Windows you can save yourself a lot of trouble by editing the javaOpts parameter. The parameter maxheap isn't used anymore, so you can set javaOpts like this in RunWeka.ini file:
javaOpts= -Xmx1040m
Where 1040m is the amount of memory you want to allocate.
Mind that the file is case sensitive.
There are a lot of ways to set this up, but this is the faster way to get Weka runing on a Windows environment at this version.
Edit: If you want Weka to use more than 1gb on windows, you need to have JDK installed. Regular JRE wont do it.
The official Weka answer (for all operating systems and Weka versions) can be found on http://weka.wikispaces.com/OutOfMemoryException.
In case you are using a recent Weka version on Windows, the answer is:
Modify the maxheap parameter in the RunWeka.ini file.
On Ubuntu i had the same problem
but i solve it by increasing the amount of memory to use for the Java Virtual Machine
run this : weka -m 1024m
You need to specify a classpath after -classpath, similar to the PATH env variable you need to specify the path where Java can find the classes.
The -Xmx500m setting looks fine, except that I would suggest to use 512m.
For Mac OS, you have to edit a configuration file in order to increase the heap size of the Weka UI application.
I am repeating what I wrote in: Is there a workaround to solve "Java heap space" memory error when the max heap value has been already specified?
Quit out of Weka if it is running.
cd into /Applications/weka-XXX.app/Contents , or wherever your weka executable was installed. There will be a file called Info.plist there. It is an XML text file. I suggest you save a copy of it to another location, as you'll need to edit it in the next step.
Open the Info.plist (XML) file in your favorite text editor and look for a block that says "VMOptions". There should be a value that says "-Xmx256M" or something similar that specifies the maximum heap size. You should change that value to something bigger, such as "-Xmx1024M".
Start Weka.
I am running Weka 3.6 in windows. This is what i did.
Go to the Weka installation directory and you will find a RunWeka.bat file. Open this file in a text editor and add -Xmx argument in the java command line.
for instance this sets to 4GB memory,
%_java% -Xmx4096m -classpath . RunWeka -i .\RunWeka.ini -w .\weka.jar -c %_cmd% "%2"
The official Weka answer is right..But....crucial is to first get rid of all JVM files and install the relevant 32 or 64 bit Java version. Not using the relevant version causes many problems including the impossibility to increase the heap further than 1024m (by changing the ini file).
Weka 3.9.2 also does not has the option of maxheap anymore. RunWeka.ini have the option of javaOpts, So you may change the below to your required memory allocation,
javaOpts=%JAVA_OPTS% ---- > javaOpts= -Xmx1024m
Here 1024m is the customised amount of memory you want to allocate.
The best way to do it using this command
java -Xmx1024m -[weka classifier] -t [training file path]
The answers above are too old (last one is 1 year ago).
I had same issue with my WEKA (version 3.8.1) on Windows 10.
I had a problem to update the heap size , the way I fixed it is by adding an environment variable (under control panel) as follows:
JAVA_OPTS = -Xms30000m -Xmx30000m
Tip: Just ensure that RunWeka.ini is using this environment variable.
In the above example I give WEKA 30GB. It works.
Hope it will be helpful for some people.
You should also see if default thread stack size 20MB is enough. Increase the value to 50MB in the file /Applications/weka-3-8-1-oracle-jvm.app/Contents/Info.plist (on MAC) like below:
<string>-Xss50M</string>
If we are using Weka Workbench CLI or Knowledge explorer we need to
change as below.
As the documentation suggests the runtime parameter should be -Xmx[size_required]m where [size_required] is memory size you intend to keep to avoid memory exception.
Open RunWeka.ini
Define maxheap=[size_required]G
In my case I kept maxheap=4G , One can set like maxheap=4096m and add -Xmx#maxheap# to all the run options at # setups (prefixed with "cmd_") sections next to java commands
like below
cmd_default=javaw -Xmx#maxheap# ...............
cmd_console=cmd.exe /K start cmd.exe ..................
cmd_explorer=java -Xmx#maxheap# .................
cmd_knowledgeFlow=java -Xmx#maxheap#....................
maxheap=4G
Verify the same by restarting Weka and Help>>SystemInfo
If you run weka from the command line but not through java i.e. typing weka into the command line, instead of typing
weka
specify the memory flag
weka -m 1024m
This will specify 1024 megabytes.
If you're running weka via weka.sh, you can directly run it with memory option.
For example,
sh weka.sh -memory 10g
This will increase the heap size to 10Gb (tested using Weka 3.8.4 on Ubuntu 18.04)
Sometimes on the start STS hangs.
Does it possible found the reason? May be exists log or possible start in debug mode?
Also how I can distinguish between hangs completely and working very slowly?
Thanks.
P.S. How to fix ?
That is usually for the same resons descibed here tricks-to-speed-up-eclipse.
Garbage collection or validation.
If you have enough RAM I would suggest that you set -Xmx768m or higher (in eclipse.ini).
Under Windows->Preferences->Validation you can switch off a lot of stuff.
My STS hanged when I tried to start it. Couldn't tell why.
Doing this fixed things for me:
Shut down eclipse and then navigate to /.metadata/.plugins/org.eclipse.core.resources and remove the .snap file.
Courtesy: https://doctorjw.wordpress.com/2011/12/05/eclipse-locking-upnot-responding-try-this/
There's a log file I think it's in .metadata/.log in the workspace used. To see if memory causes the issue, and it usually does, try to run jconsole (part of the JDK) and connect to the running eclipse process, and see the memory stats.
Ensure that STS is running with admin privileges to avoid permission problems.
In ubuntu edit the following line in STS.desktop launch file:
Exec=gksu /etc/springsource/sts-3.4.0.RELEASE/STS
Complete file:
[Desktop Entry]
Name=STS
Comment=SpringSource Tool Suite
Exec=gksu /etc/springsource/sts-3.4.0.RELEASE/STS
Icon=/etc/springsource/sts-3.4.0.RELEASE/icon.xpm
StartupNotify=true
Terminal=false
Type=Application
Categories=Development;IDE;Java;