How do I provide JVM arguments to VisualVM?
Solution 1
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
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
I started with
jvisualvm -J-Xms1024m -J-Xmx2048m
and it worked.
Solution 4
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
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
Related videos on Youtube
Mike Partridge
I love software development, and technology of all kinds. I have a boy and a girl and a beautiful wife, all of whom I adore. I practice Traditional Chinese Kung Fu, and hope that my kids will too. I write code and play boardgames in my spare time. I currently work as a software engineer in Golden Valley, MN.
Updated on May 11, 2021Comments
-
Mike Partridge almost 3 years
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?
-
Mike Partridge about 12 yearsI couldn't get this to work. I tried
jvisualvm.exe -J-Xms256m -J-Xmx1024m
from the command prompt, and when inspecting the process, I could see that the arguments were not applied. -
Kevin Welker about 12 yearsI just tried it and it appears to append it. So I'm seeing the default 192m and also another entry for 1024m. It looks like the latter takes precedence. What version JDK?
-
Mike Partridge about 12 yearsI'm using 1.6.0_26. When using JConsole to inspect the VisualVM process, the VM arguments section on the VM Summary tab shows the defaults and the values I provided, but when using VisualVM to inspect itself, in Overview > JVM arguments it reports the defaults only.
-
Kevin Welker about 12 yearsI'm using 1.6.0_20, and I see 2 lines that list Xmx. The first is the default, and the latter one is the new value. I copied your command line directly from your comment above just to be certain. Output in Overview>JVM includes:
-Xms24m -Xmx192m -Dsun.jvmstat.perdata.syncWaitMs=10000 -Xms256m -Xmx1024m
-
Jonas N over 11 yearsOn (my copy of :) OSX: /System/Library/Java/Support/VisualVM.bundle/Contents/Home/etc/visualvm.conf
-
GreenGiant about 11 years@Zack Can you confirm that
-J-Xms
and-J-Xmx
are actually the correct option names? Is the-J
prefix necessary when these are specified in the conf file? -
Zack Macomber about 11 years@GreenGiant I'm not sure if they are or aren't...In my copy of visualvm.conf, I have
-J-Xms24m
&-J-Xmx256m
so I assume that is the correct option names. You could probably google how to format visualvm.conf for more info... -
GreenGiant about 11 years@Zack my conf file is the same as well. Just wanted to confirm since your answer didn't include the
-J
prefix. -
prashant almost 11 yearsFYI, on Linux (Mint, presumably Ubuntu as well) it's
/usr/lib/jvm/java-6-sun/lib/visualvm/etc/visualvm.conf
. -
Martijn Pieters about 8 yearsPlease keep your answer focused on the solution. If you want to add meta-information, do so in a comment please.
-
Martijn Pieters about 8 yearsAnd with the question tagged windows, your answer is going to hard to find for Mac users. Consider making it a new question anyway.
-
Martijn Pieters about 8 yearsI did not vote on this post, please don't jump to conclusions.
-
aspdeepak about 8 yearsWhy would you do an unnecessary edit to this answer? To gain some more reputations? The answer was already focused and crystal clear. BTW, with each of your edits I'm having a down rating!
-
Martijn Pieters about 8 yearsI've made one edit here, and made it clear why I did so. If you want to insist on adding a Mac-only answer to a question aimed at Windows users by tags, that's fine, but keep meta info out of it; your post should contain a solution only, not voting advice.
-
Dmitry almost 8 yearsOn (my copy of :) latest OS X 10.11: /Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk/Contents/Home/lib/visualvm/etc/visualvm.conf
-
George Co over 7 yearsI like this because the location of the .conf file has changed but this still works and presumably would work for at least some other Java programs, Contrary to comments above this is not hard to find for Mac users. The world uses Google which brings us here.
-
George Co over 7 yearsAs noted in the comments below, inside of jvisualvm when you look at VM args it seems it is not working but it does. I no longer get an OOM error.
-
Shannon over 7 yearsIf you're using JVisualVm as part of a JDK installation, it might be located on a path like
/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/lib/visualvm/etc/visualvm.conf
-
Kranach over 3 yearson my Mac it was /Applications/VisualVM.app/Contents/Resources/visualvm/etc/visualvm.conf
-
Diego Ramos over 3 yearsCould you please explain what is the meaning of -J? Thanks.
-
Diego Ramos over 3 yearsCould you please explain what is the meaning of -J? Thanks
-
Kevin Welker over 3 yearsThis is so long ago, I don't remember my source. But if you look at all the other answer on this page, you will notice that every argument to jvisualvm that is meant to be added to the JVM runtime is preceded by -J. Sort of like an escape sequence to indicate that the argument that follows is not meant to be processed by jvisualvm itself, but rather used to modify the JVM that jvisualvm uses.
-
Florian Kirmaier almost 3 yearsI can confirm Kranach's comment, that this is the new path.