[GUIDE] Finding the Cause of a RAM Issue

Discussion in 'Performance Tweaking' started by Captain_Obvious, Sep 10, 2017.

  1. Finding the Cause of RAM Issues
    Hi everyone. This guide will help you determine issues with RAM on your server. After opening up my own server, I often had issues with RAM randomly being drained. I was quickly able to find the issues using this method.

    Step 1 - Install HeapDump and create a Heap Dump
    This plugin will create a heap dump of the server. It will gather data of all the process using the server RAM. This is quite a small plugin but it very useful. Once the plugin has been installed on the server, use the command /dumpheap <filename>. Depending on how much RAM is being used, it can take awhile. If you have 1GB+ of ram being used, this will most likely disconnect your players, so it recommend you do this while your server is whitelisted. Please note that your entire server will freeze while the file is being created. It will let you know when it is finished. Once it is finished, locate the file in your server directory and download it to your desktop.

    Step 2 - Download Eclipse Memory Analyzer (MAT)
    This program will help us read the heap dump we have created. Once it is downloaded, drag the folder to your desktop. Before opening the exe, you will want to configure it based on the file you created. Go to /mat/MemoryAnalyzer.ini and open it with your preferred text editor. On the last line, you will see "Xmx1000m". You will want to change this based on how large the file is. If your server is using about 3GB of ram, I would set it to "Xmx3150m". This is the same way you would change ram for your server.

    Step 3 - Open your Heap Dump
    Once everything is setup, open MemoryAnalyzer.exe. This will take a little bit to open up based on your computer. Once open, Go to File > Open Heap Dump and find your heap dump that you created on your desktop. Once you open it, it will start parsing it. Please note that this will create items on your desktop. You can safely delete them when you are done viewing the heap dump. This may take awhile based on the size of your Heap Dump. Once it has been parsed, it will message you about common actions you can do with your heap dump. You can go ahead and hit cancel. From there, you will see a pie chart of how your servers RAM is being used.

    Step 4 - Finding the cause
    Now that you have your heap dump open, you will now be able to find the cause. You may see one process take up the majority of the chart. Hover your mouse over that process and you will see a name by the bottom left of the chart. Such as, "org.bukkit.craftbukkit.v1_xx_R1.CraftServer" This is the process that is your issue (Not the process used in the example. It's specific to you.) From the name, you may be able to already tell the cause. If it is displaying a name connected to the actual server, such as "org.bukkit.x" You will need to dig a little deeper. Click on the process, go to List Objects > With outgoing references. This will redirect you to another tab inside the analyzer. Click on the small arrow to the left to drop all the process inside that one process. You will also need to double click on the bottom where it says "...x More" and it will drop more process in the table. From there, look in the "Retained Heap" column and find the largest number. On the left, it will give you a name of that specific process. This is the cause of your issue. Usually its pretty self-exploratory of what it is. From there, you will need to think about plugins that may interact with that process. For example, if your process is "entityMetadata", you will need to think of plugins that may interact with mobs or entity's. I have the plugin MobStacker which renames every mob and stacks them. I can then see in game that I have over 2,000 mobs spawned and from there MobStacker is the cause of my RAM issue. I removed it and gained 800MB back to my server.

    If you get an error every time you try to parse a heap dump that means you do not have enough RAM allocated to the analyzer.

    If you have a larger server with a lot of ram being used, you could lead into some problems. When my server was using about 3 GB, it froze for about 15 seconds. You will see your TPS drop down to around 1 during the time it is creating the file. You can also try running the command from console.

    If you are having problems figuring out the issue, feel free to post a screenshot of your listed objects and I could help you.

    Thanks for reading! Feel free to ask any questions below.
  2. Great tutorial, I personally have had memory leaks and have used this method.

    If anyone here prefers video tutorials, you can find one here:


    Feel free to include this in your main post if you wish.
  3. I will cry. I have worked like 3months trying to figure out what was wrong. This realy helped me <3 Ur welcome to recive my best rank Legend on my server. I realy presure it. I found out it was some mysql connection, but i have not found what plugin who cause it but this lead was very helpful. I will search more tof ind out what.
    • Like Like x 1
  4. Glad it helped. I would recommend posting your problem on the forums to get input for other users to help fix your issue.

Share This Page