[WIP] Analysis of your server JVM using VisualVM

Discussion in 'Resources' started by md_5, Mar 22, 2012.

  1. Offline

    md_5

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Many server owners come to ask the question, why is my server using soo much ram? Why is my server laggy since the <insert version here> update? Well there is an easy way to inspect the insides of your server yourself.
    I point you here to the VisualVM tool. The following thread will be a screenshot laden tutorial on how to use VisualVM to gain an inside view of your server and an edge over the competition.

    Step 1: Download VisualVM from here. It will work on any system with java that has a gui.
    Step 2: Extract it to a folder of your choice.
    [IMG]
    Step 3: Prepare your server to be introspected by VisualVM, you can do this by adding the following to your server startup script: -Dcom.sun.management.jmxremote
    Now is also a good time to take a look at all those fancy flags people have encouraged you to put in that script. Be warned many of them lead to increased crashes, memory consumption or other nasty effects. Should experimental weapons really be used on your server?
    How this for simple:
    [IMG]
    Step 4: Start up your server and VisualVM (find it in the bin/ folder), you will be greeted with a screen like so: [IMG]
    Step 5: Take a look at what you see. I currently have four java applications running on my computer, Netbeans, my Minecraft launcher, my server and of course VisualVM.
    Step 6: Double click on the CraftBukkit entry, you will be greeted with a screen like below. This is the main control panel for all the options you may perform on your Java VM. I will be going through all of them over the next few posts.
    [IMG]

    This post has been edited 1 time. It was last edited by md_5 Mar 22, 2012.
    jtjj222, hawkfalcon and Don Redhorse like this.
  2. Offline

    md_5

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Getting to know your way around VisualVM:
    The main feature of VisualVM that we will be using to sample our server is the heap dump. Those of you who develop a lot of plugins will be familiar of the debug function provided by your idea (<3 Netbeans) a heap dump is sort of like this in the sense that it displays the values of variables and classes, but it is very broad in the sense that it dumps the ENTIRE application heap for your inspection.
    [IMG]
    As we can see from the monitor tab, various metrics about the performance of CraftBukkit are shown, namely CPU, memory, the number of classes loaded and threads active. We are interested in the Heap Dump button, present in the top right corner. Click this button and you will be presented with a new tab, the heap dump you just took.
    [IMG]
    Now from this view, there is only one tab that we need access to one tab, the Classes one, click this and you are presented with a myriad of complicated strings.
    [IMG]

    This post has been edited 3 times. It was last edited by md_5 Mar 22, 2012.
    fromgate likes this.
  3. Offline

    md_5

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Advanced use of VisualVM:

    This post has been edited 1 time. It was last edited by md_5 Mar 22, 2012.
    [Furq] likes this.
  4. Offline

    tips48

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    *cricket*
    Good so far, going to setup tomorrow!
  5. Offline

    md_5

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Sarcasm?
  6. Offline

    tips48

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    No, serious. Joke twas about the blank Advanced use of VisualVM
  7. Offline

    md_5

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Originally it was "--Reserved for future use"
    But I didn't think that really fitted. Part 2 isn't finished either.
  8. Offline

    Technius

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Looks pretty useful.
  9. Offline

    gaz492

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Shame that the screen shots are missing as i would like to know how to set it up properly.
  10. Offline

    md_5

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Restored via Dropbox :)
  11. Offline

    gaz492

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
  12. Online

    chaseoes Retired Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Ever going to finish it?
  13. Offline

    md_5

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I don't plan to :|
  14. Offline

    hawkfalcon

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Please do:)
    How do you look at each plugin individually?

    This post has been edited 1 time. It was last edited by hawkfalcon Jul 29, 2012.
  15. Offline

    TNTUP

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Gotta try it, seems useful and awesome.

    is the bottom right the TPS? I see 20, I think its the TPS.

    EDIT: sadly it doesn't monitor TPS... well tps are minecraft only, not oracle java. Btw I like the visualVM program.

    This post has been edited 2 times. It was last edited by TNTUP Sep 25, 2012.
  16. Offline

    ray73864

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Can this monitor a remote server? i see no benefit in something like this when the server and the computer with VisualVM are 2 completely different systems if it cannot do that.
  17. Offline

    zack6849

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    file>add remote host, so i assume you most certainly
    can.
  18. Offline

    Gyldenglad

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I'm trying to use this program to analyse why my server suddenly goes "Read timed out". To see where the error might be.
    However it seems that this guide lacks the part where it actually explains what to look at. What exactly does these tabs mean and so on.

    Here's my thread: http://forums.bukkit.org/threads/server-time-out-error.105596/#post-1378307

    Please continue/update this guide so I can stop the daily crashes on my server, would be much appreciated.
  19. Offline

    silthus

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    So I got it all setup on a Linux mashine with no desktop environment.

    Is there still a way to live debug the server without having to download the heap dump when its generated?
  20. Offline

    md_5

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I think X11 forwarding is apparently the way to go.
  21. Offline

    FTWin01Gurl

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    The way you said Heap Dump made me chuckle. It sounded like a pile of poop in this statement:

    -_Husky_- likes this.
  22. Offline

    Kainzo

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    You mind helping me re-setup mine? It keeps me giving me a unknown host and I'm not sure what exactly is going wrong. Everything appears to be setup correctly, ports forwarded etc.
  23. Offline

    NotYetRated

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    This is excellent, much more indepth than the nolagg/examine that I have been using. Thanks!
  24. Offline

    iZanax

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    But how can I determine if there is a Memory Leak?
    Or something else what causes too many RAM usage?

    I got some several graphics pictures and head dump classes, but I don't understand what I can do with them to see if the plugin is doing something strange, I need a reference point to know what is normal..

    Head Dump - Classes: (is this acceptable?)
    • char[] 25%
    • String 25%
    • Object 13%
    • byte 10%
    Some explanation to use this program to debug some problems would be nice.
    Since problems with RAM is the most common and this could help.
    Thank in advance,
    Zanax
  25. Offline

    lDucks Retired Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @md_5 great guide on VisualVM, this would have been helpful when I was learning how to use it ;P

    I added a link to your guide in my guide.
  26. Offline

    NotYetRated

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME

    You are having RAM issues? Got a plugins list? I have been through quite a few plugins and do not tend to have any RAM issues really. Not while using MD_5's excellent tweaks anyways.
  27. Offline

    iZanax

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Tweaks? where...

    The problem is I've one main server plugin and I find it hard to determine if it is using too much RAM for what it does or not. So what can I do?
  28. Offline

    kaise123

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Is this going to be updated? :D it's been a while and the 'advanced usage' is still blank. This is a very useful guide, Thanks :D
  29. Offline

    Eaglesight

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I'd like to extend my deepest gratitude to both nallar and md_5 for helping me understand VisualVM better. In return, I shall continue on this matter and inform others who want to analyse their servers.

    Once you have VisualVM setup, and have selected your server process. During times of low TPS, click Sampler and then the CPU button. Wait 5 minutes~ and click Snapshot. Order by Time(CPU) and then you'll have loads of data to analyse. This way you can see what functions are taking up abnormal amounts of CPU Time.

    Expand the threads & functions which take alot of time to perform.

    In the end, you should have something like this, which will tell you exactly what function is causing problems.
    [IMG]
  30. Offline

    Chunkr

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Ooh, Thanks for this! :)

Share This Page