Help needed profiling memory (Memory leak)

Discussion in 'Performance Tweaking' started by Mithrandir, Jul 20, 2018.

  1. Hi, I need some advice in order to detect a memory leak causing server inconectibity aproximately every 12h with an "Out Of Memory" error message on console.
    My initial thoughts on this are the logical plugin memory leak suspicions.

    Therefore I'd appreciate directions on how to analize ram memory usage on my Ubuntu OS where my server is hosted, the analisis results should be precise enough as to determine which plugin/s may be causing the memory leak.

    Thanks in advance. Any information needed about my server or host will be provided.
     
  2. Weaves

    Resource Staff

    I use VisualVM. Select your server in the VM tree on the left side. Then go to the profiler tab. Select memory and watch for classes that keep going up and up as you play but then dont occasionally drop back down.
     
  3. @Weaves Mmmm but I use just Ubuntu with terminal. No graphical interface. Can I still use VisualVM? I actually already attempted to install it but it didn't go well. Is there any documentation on it you can point me to?
     
  4. Weaves

    Resource Staff

    Good question. I think there are some remote options but I am not sure on compatibility or how it works. https://docs.oracle.com/javase/8/docs/technotes/guides/visualvm/
     
  5. Or make a heap dump and look through that with eclipse memory analyzer (or similar tool).
     
  6. @Mareckoo01 I have no idea how to do this. That's why I'm asking. Even just documentation on such subjects would be helpfull.
     
  7. By googling "java heap dump" you can find dozen of ways on how to do a heap dump.
    By googling "eclipse memory analyzer" your first result is where you can download it.
    Then just open the heapdump in it, select "leak suspects report" and look through it.

    For example: i was looking for memory leak in sevtech and found out that it was caused by particle queue not being cleared and keeping milions of particle instances..
     

    Attached Files:

    • 1.png
      1.png
      File size:
      109.6 KB
      Views:
      260
  8. @Mareckoo01 I tried the command:
    jmap -dump:file=dump1.hprof <pid>
    But it messes up the stability of my network really badly, causing various crashes and lag spikes. I fear the report may not even be complete since it referenced a process related to the server that crashed, thus possibly being interrumped. So it looks like I can't even make a propper memory dump without seriously affecting my server's performance. Any advice on this?
     
  9. Well.. heap dump means saving contents in ram to file, if your server has 8GB ram it will create 8GB file, if you use HDD or slow SSD then it freezes the server for too long so when it finishes, the server will think it crashed so it will exit, (i haven't experienced that since i have 2 SSDs in raid 0) so maybe try using the jvm args to make heap dump on OOM error?

    If you run multiple mc servers on your server and one of those starts saving the world(or any sync i/o operations) while you are making the heap dump it might crash too since it might take too long..
     
  10. Easy. Put this plugin into your spigot server: https://www.spigotmc.org/resources/heapdump.1433/

    Once done, use MAT or any other java analyzer to analyze the hprof file. The file will generate into your home directory and all you have to do from there is extract it to your PC, and open the snapshot using one of the programs I mentioned above.
     
    • Like Like x 1
  11. @Stilled Ok, that sounds good, I can do it both ways I guess, I'm just hoping that plugin doesn't lag the whole network also x'D
     
  12. It will lag the server for about 20 seconds, but after that it should be fine as long as that you don't have a bunch of ram allocated. If you need any other help feel free to add me on discord @ Stilled#0513
     
  13. @Stilled Thanks, I tried it once, 0 lag. Must be because the memory dump is much more precise.