How do I provide JVM arguments to VisualVM?

JavaWindowsJvmVisualvm

Java Problem Overview


I'm using VisualVM from JDK 1.6.0_26 to profile a Java webapp running under Tomcat, but VisualVM often tells me that it doesn't have enough memory to take a snapshot, and to use the -Xmx switch to provide more memory to Netbeans. The problem is, I'm running VisualVM outside of Netbeans, so how can I provide JVM arguments to jvisualvm.exe?

Java Solutions


Solution 1 - Java

Should be able to modify the memory settings in %JDK_HOME%\lib\visualvm\etc\visualvm.conf

Xms and Xmx are in the default_options line.

Solution 2 - Java

or I think this works too:

jvisualvm.exe -J-Xmx512m (or whatever amount you need)

-J on the .exe command line for onetime settings, or the .conf file noted in the other answer for changing defaults

Solution 3 - Java

I started with

jvisualvm -J-Xms1024m -J-Xmx2048m

and it worked.

Solution 4 - Java

In mac, you can configure them by editing this file.

/Applications/VisualVM.app/Contents/Resources/visualvm/etc/visualvm.conf

visualvm_default_options="-J-client -J-Xms4096m -J-Xmx5120m -J-XX:+IgnoreUnrecognizedVMOptions -J-Dnetbeans.accept_license_class=com.sun.tools.visualvm.modules.startup.AcceptLicense -J-Dsun.jvmstat.perdata.syncWaitMs=10000 -J-Dsun.java2d.noddraw=true"

Solution 5 - Java

Update:

As per the comment from @Kranach. New path is /Applications/VisualVM.app/Contents/Resources/visualvm/etc/visualvm.conf. In this configuration file, you can change the

visualvm_default_options="-J-client -J-Xms24m -J-Xmx256m

to(e.g.)

visualvm_default_options="-J-client -J-Xms24m -J-Xmx2048m

Old Answer: For Mac OSX 10.12+

If you have downloaded the visualvm dmg from https://visualvm.github.io/download.html and have moved it to the Applications directory. You can find the configuration file visualvm.conf under the location Applications/VisualVM.app/Contents/etc/visualvm.conf. In this configuration file, you can change the

visualvm_default_options="-J-client -J-Xms24m -J-Xmx256m

to(e.g.)

visualvm_default_options="-J-client -J-Xms24m -J-Xmx2048m

Solution 6 - Java

In VisualVM 2 the config file is in the VisualVM directory where the downloaded file was extracted, in etc/visualvm.conf

${VISUALVM}/etc/visualvm.conf

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMike PartridgeView Question on Stackoverflow
Solution 1 - JavaZack MacomberView Answer on Stackoverflow
Solution 2 - JavaKevin WelkerView Answer on Stackoverflow
Solution 3 - JavaPrabhat JhaView Answer on Stackoverflow
Solution 4 - JavaaspdeepakView Answer on Stackoverflow
Solution 5 - JavaHardik ModhaView Answer on Stackoverflow
Solution 6 - JavaisapirView Answer on Stackoverflow