I am creating a module in netbeans to help with a project i am working on however when I run the module in the developmental IDE i get an out of memory exception while loading an asset. This procedure seems to work fine in the base netbeans environment but when i make the same calls during module development i get the error. After attempting to load the asset in several differnt ways i tried appending the following to project.properties and then to Netbeans Platform config(platform.properties)
netbeans_default_options="-J-Xms384m -J-Xmx1024m -J-XX:PermSize=32m -J-XX:MaxPermSize=96m -J-Xverify:none"
and also tried
netbeans_default_options="-J-client -J-Xverify:none -J-Xmx1024m -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true"
I have also tried
test.run.args=-ea -Xms1024m -Xmx1024m
I was stuck in this issue for a while. Adding this line into project.properties has solved the problem:
run.args.extra=-J-Xms128m -J-Xmx512m -J-XX:MaxPermSize=512m
While it improved the heap memory size, apparently the problem was gone because of the increased non-heap memory size (J-XX:MaxPermSize=512m).
Good luck
If the problem occurs when you install your module in the development IDE, you can configure the maximum heap size and perm size in <netbeans-install-dir>/etc/netbeans.conf by appending your -J-Xmx and -J-XX:MaxPermSize parameters to the netbeans_default_options variable. You should also append -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled, as noted in the docs (see http://wiki.netbeans.org/FaqGCPauses).
Had a similar memory problem on my Linux Debian.
Only Works on linux / possibly UNIX OS's???
Here is how to fix it:
run a terminal
log in as root
type crontab -e
scroll to the bottom or the file and type * * * * * sync; echo 3 > /proc/sys/vm/drop_caches
This magic line cleared all unused ram every minute. It removed the unused memory NetBeans was producing (including any other memory-consuming programs).
plz tell me if this works.
solution to Out of memory exception in netbeans is![.....][1]
I have tried by setting project properties.
right click on project --> select Properties-->General Settings-->VM Options
Add below parameters -Xms256m -Xmx512m
Related
I am trying to update IntelliJ IDEA from build 141.177 to 141.178.
When the updated downloads all the files needed, and starts the update, I get this error:
Temp. directory: /tmp
java.lang.OutOfMemoryError: Java heap space
at ie.wombat.jbdiff.JBPatch.bspatch(JBPatch.java:91)
at com.intellij.updater.BaseUpdateAction.applyDiff(BaseUpdateAction.java:112)
at com.intellij.updater.UpdateAction.doApply(UpdateAction.java:44)
at com.intellij.updater.PatchAction.apply(PatchAction.java:184)
at com.intellij.updater.Patch$3.forEach(Patch.java:308)
at com.intellij.updater.Patch.forEach(Patch.java:360)
at com.intellij.updater.Patch.apply(Patch.java:303)
at com.intellij.updater.PatchFileCreator.apply(PatchFileCreator.java:84)
at com.intellij.updater.PatchFileCreator.apply(PatchFileCreator.java:75)
at com.intellij.updater.Runner.doInstall(Runner.java:295)
at com.intellij.updater.Runner.access$000(Runner.java:18)
at com.intellij.updater.Runner$2.execute(Runner.java:261)
at com.intellij.updater.SwingUpdaterUI$5.run(SwingUpdaterUI.java:191)
at java.lang.Thread.run(Thread.java:745)
The /tmp folder should be on my root partition which has 20GiB of size, and currently it still has about 8GiB left. So I don't really understand what the problem could be here right now. Plus I am not sure about the RAM part, my system is using 40% of my RAM when I do the update.
I hit this same problem. The issue is that idea.vmoptions change the memory for the main intellij process but not the update process. In my case the update process only had 500m allocated to it.
I got past the problem by leaving the update window open after it got the error. I then ran ps -Af | grep java (I'm running linux). This showed me the command line for the update process. I copied it out and changed -Xmx500m to -Xmx1024m. I then ran the modified command line in another console, once it was done I exited the original update window and all was good.
Read the JetBrains documentation & this answer about how to increase the maximum heap size for IntelliJ.
Set -Xmx2048m in idea.vmoptions (32-bit edition) or idea64.vmoptions (64-bit edition), and copy it to the appropriate location, according to the documentation I referred to above.
I would also do File > Invalidate Caches / Restart > Invalidate and Restart, just to be sure that the changes took (probably not necessary, but just in case).
I received the exact same stack trace today while attempting to upgrade from 14.1.1 to 14.1.2 via the automatic updater. On OS X, I solved it by renaming ~/Library/Preferences/IdeaIC14/idea.vmoptions to idea64.vmoptions. I already had -Xmx2048m set in that file, but apparently it wasn't being read until I renamed it correctly.
Also see YouTrack issue IDEA-139036 (thanks to #Meo).
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)
There are lots of questions that ask this or a similar question.
They all give the command that has to be executed, what I don't understand is where do I write this command. I want to permanently increase the heap space for my tomcat apps.
I read this page http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html and it says under the Tomcat section
Stop Tomcat server, set environment variable CATALINA_OPTS, and then restart Tomcat. Look at the file tomcat-install/bin/catalina.sh or catalina.bat for how this variable is used. For example,
set CATALINA_OPTS=-Xms512m -Xmx512m (Windows, no "" around the value)
export CATALINA_OPTS="-Xms512m -Xmx512m" (ksh/bash, "" around the value)
setenv CATALINA_OPTS "-Xms512m -Xmx512m" (tcsh/csh, "" around the value)
So I replaced the line
set CATALINA_OPTS=
with
set CATALINA_OPTS=-Xms512m -Xmx512m
But I still get the error.
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.OutOfMemoryError: Java heap space
java.lang.reflect.Array.multiNewArray(Native Method)
java.lang.reflect.Array.newInstance(Array.java:90)
nom.tam.util.ArrayFuncs.newInstance(ArrayFuncs.java:1028)
nom.tam.fits.ImageData.read(ImageData.java:259)
nom.tam.fits.Fits.readHDU(Fits.java:573)
controller.UploadServlet.retreiveFITSFileFields(UploadServlet.java:206)
controller.ScanServerFiles.doPost(ScanServerFiles.java:39)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
There is a mechanism to do it without modifying any files that are in the distribution. You can create a separate file %CATALINA_HOME%\bin\setenv.bat or $CATALINA_HOME/bin/setenv.sh and put your environment variables there. Further, the memory settings apply to the JVM, not Tomcat, so I'd set the JAVA_OPTS variable instead:
set JAVA_OPTS=-Xmx512m
First of all you cannot change the memory settings only for a tomcat application but rather for all tomcat instance.
If you are running tomcat from console (using startup.bat) you'll need to edit catalina.bat and play around with CATALINA_OPTS. For example:
set CATALINA_OPTS=-Xms512m -Xmx512m
Restarting tomcat will apply the new settings.
If you are still getting OutOfMemoryError you need to know how much memory does your application need at that particular moment (nom.tam.util.ArrayFuncs...). You'll either have to optimize the application or simply increase the memory provided to tomcat.
Your change may well be working. Does your application need a lot of memory - the stack trace shows some Image related features.
I'm guessing that the error either happens right away, with a large file, or happens later after several requests.
If the error happens right away, then you can increase memory still further, or investigate find out why so much memory is needed for one file.
If the error happens after several requests, then you could have a memory leak - where objects are not being reclaimed by the garbage collector. Using a tool like JProfiler
can help you monitor how much memory is being used by your VM and can help you see what is using that memory and why objects are not being reclaimed by the garbage collector.
Open the server tab in eclipse
right click open
click on open lauch configuration
Go to arguments
Here you can add in VM arguments after endorsed
-Xms64m -Xmx256m
You need to add the following lines in your catalina.sh file.
export CATALINA_OPTS="-Xms512M -Xmx1024M"
UPDATE : catalina.sh content clearly says -
Do not set the variables in this script. Instead put them into a script setenv.sh in CATALINA_BASE/bin to keep your customizations separate.
So you can add above in setenv.sh instead (create a file if it does not exist).
Easiest way of doing is: (In Linux/Ububuntu e.t.c)
Go to tomcat bin directory:
cd /opt/tomcat8.5/bin
create new file under bin directory "setenv.sh" and save below mention entries in it.
export CATALINA_OPTS="$CATALINA_OPTS -Xms512m"
export CATALINA_OPTS="$CATALINA_OPTS -Xmx2048m"
export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=256m"
and issue command:
./catalina.sh run
In your catalina log file you can see entry like this:
INFO [main] VersionLoggerListener.log Command line argument: -Xms512m
INFO [main] VersionLoggerListener.log Command line argument: -Xmx2048m
INFO [main] VersionLoggerListener.log Command line argument: -XX:MaxPermSize=256m
Which confirms that above changes took place.
Also, the value of "Xms512m" and "-Xmx2048m" can be modified accordingly in the setenv.sh file.
Startup of tomcat could be done in two steps as well.
cd /opt/tomcat8.5/bin
Step #1
run ./setenv.sh
Step #2
./startup.sh
If you're using systemd edit:
/usr/lib/systemd/system/tomcat8.service
and set
Environment=CATALINA_OPTS="-Xms512M -Xmx2048M -XX:MaxPermSize=256m"
if you are using Windows, it's very simple. Just go to System Environnement variables (right-clic Computer > Properties > Advanced System Parameters > Environnement Variables); create a new system variable with name = CATALINA_OPTS and value = -Xms512m -Xmx1024m. restart Tomcat and enjoy!
For Windows Service, you need to run tomcat9w.exe (or 6w/7w/8w) depending on your version of tomcat.
First, make sure tomcat is stopped. Then double click on tomcat9w.exe. Navigate to the Java tab. If you know you have 64 bit Windows with 64 bit Java and 64 bit Tomcat, then feel free to set the memory higher than 512. You'll need to do some task manager monitoring to determine how high to set it. For most apps developed in 2019... I'd recommend an initial memory pool of 1024, and the maximum memory pool of 2048. Of course if your computer has tons of RAM... feel free to go as high as you want.
Also, see this answer: How to increase Maximum Memory Pool Size? Apache Tomcat 9
you can set this in catalina.sh as CATALINA_OPTS=-Xms512m -Xmx512m
Open your tomcat-dir/bin/catalina.sh file and add following line anywhere -
CATALINA_OPTS="$CATALINA_OPTS -Xms1024m -Xmx3024m"
and restart your tomcat
Just set this extra line in catalina.bat file
LINE NO AROUND: 143
set "CATALINA_OPTS=-Xms512m -Xmx512m"
And restart Tomcat service
I'm using ASANT to run a xml file which points to a NARS.jar file.
I'm getting "java.lang.OutOfMemoryError: Java heap space" and i'm researching around this.
So i have found that i need to set "-XX:+HeapDumpOnOutOfMemoryError", to create a dump file to analyze.
I edited ASANT.bat and added the "-XX:+HeapDumpOnOutOfMemoryError" to ANT_OPTS:
set ANT_OPTS= "-XX:+HeapDumpOnOutOfMemoryError" "-Dos.name=Windows_NT" "-Djava.library.path=%AS_INSTALL%\lib;%AS_ICU_LIB%;%AS_NSS%" "-Dcom.sun.aas.installRoot=%AS_INSTALL%" "-Dcom.sun.aas.instanceRoot=%AS_INSTALL%" "-Dcom.sun.aas.instanceName=server" "-Dcom.sun.aas.configRoot=%AS_CONFIG%" "-Dcom.sun.aas.processLauncher=SE" "-Dderby.root=%AS_DERBY_INSTALL%"
But i can't seem to find any dump file.
I will use the Eclipse Memory Analyzer to analyze when i find the dump.
I also tried to set the option "-XX:HeapDumpPath=c:\memdump\bds.hprof", but no dump was created there.
Anyone got an idea of what i'm doing wrong?
Thanks in advance
It looks like your application is running on Windows. A Windows file path needs to be escaped with \. As per your example, -XX:HeapDumpPath should look like:
-XX:HeapDumpPath=c:\\memdump\\bds.hprof
Besides ‘-XX:+HeapDumpOnOutOfMemoryError’ there are several other options to capture heap dumps as well.
I found that i could use VisualVM from SUN to get a heapdump, and see it live.
Easy solution
It's in the working directory of the application (i.e. where you've started it). I'm not sure what happens if the process does not have the necessary privileges to do so. Probably, writing the dump would fail silently.
are you sure that ANT is the process with the OOME ? It may be a process started by ANT.
Add "-debug" to the ANT_OPTS for debugging information.
Are you seeing the targets being printed out during the execution?
You can also fork the various processes started by ant ( will slow things down but may help isolate the culprit )
Lastly, maybe you just need more memory than the default. Add:
-Xms256m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=256m
to the ANT_OPTS
Umm... how about wherever java.io.tmpdir is pointing?