Java/plugins/bukkit RAM usage/management

Discussion in 'Bukkit Help' started by hackal, Jan 1, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    hackal

    Hi guy,

    I have problem with RAM getting full very fast and even when there are no players it doesnt lower usage of RAM. I dont know anything about java memory management. I would like to hear from you any suggestions how to manage RAM better or what/where improve.
    My pc has 4G RAM and 3G are used for bukkit.

    Ubuntu 11.10 (GNU/Linux 3.0.0-26-server x86_64)

    java version "1.7.0_09"
    Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
    Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

    Bukkit version 1.4.6-R0.3

    Plugins (13): WorldBorder, AlphaChest, WorldEdit, Vault, PermissionsEx, LogBlock, LWC, WorldGuard, Essentials, ChatManager, EssentialsSpawn, xAuth, DeathControl


    My startup script:
    (Since I have to restart server every night with crontab to "unload" everythung from RAM I have set of scripts)

    START.SH

    Code:
    #!/bin/sh
    screen -S "bukkit" bash -c "sh /home/adam/data/lostmines/loop.sh"
    
    LOOP.SH

    Code:
    #!/bin/bash
    while true
    do
            java -Xincgc -Xmx3G -jar craftbukkit.jar
            echo "If you want to completely stop the server process now, press Ctrl+C before the time is up!"
            echo "Rebooting in:"
            for i in 5 4 3 2 1
            do
                    echo "$i..."
                    sleep 1
            done
            echo "Rebooting now!"
    done
    
    RESTART.SH - this script is executed automaticly at 0:30 every night.

    Code:
    #!/bin/bash
    screen -S bukkit -X stuff "say Server restarting in 30 seconds!"
    screen -S bukkit -X eval "stuff \015"
    sleep 5
    screen -S bukkit -X stuff "save-all"
    screen -S bukkit -X eval "stuff \015"
    sleep 10
    screen -S bukkit -X stuff "say Server restarting in 15 seconds!"
    screen -S bukkit -X eval "stuff \015"
    sleep 5
    screen -S bukkit -X stuff "say Server restarting in 10 seconds!"
    screen -S bukkit -X eval "stuff \015"
    sleep 5
    screen -S bukkit -X stuff "say Server restarting in 5 seconds!"
    screen -S bukkit -X eval "stuff \015"
    sleep 5
    screen -S bukkit -X stuff "kickall Server is restarting!"
    screen -S bukkit -X eval "stuff \015"
    sleep 1
    screen -S bukkit -X stuff "stop"
    screen -S bukkit -X eval "stuff \015"
    
    If you want me to add aditional information please write in comments.

    Thank you for reply.

    PS. Happy new year!!!
     
  2. Offline

    falkensmaze

    hackal

    There are two ways to consider RAM usage when using Java, so firstly it's important to make a distinction. One measure is the amount of system memory Java is using, which is reported by system tools like vmstat, top and free. The other measure is how much Java heap space a Java application (like CraftBukkit) is using within the Java process. For this you can use a plugin like NoLagg or LagMeter to get a report. The difference is that the system memory which is in use by Java itself may actually be free memory (according to CraftBukkit) that can still be allocated on the Java heap.

    You might also want to understand the difference between physical RAM usage and memory usage (VM size), which might be different if some memory is inactive (swapped to disk or not yet modified).

    So, my first question is, what numbers are you looking at? What programs are you using for measurement?

    And also, what happens when you allow RAM to "run out"?
     
  3. Offline

    ifly6

    What is the CPU's ID/Clock/FSB/etc? Slower CPUs mean the RAM needs to be cleared more frequently. Maybe try allocating a section of RAM for your Eden threads (though my last experiments with this were not very helpful).

    Also. Don't use -Xincgc. The incremental garbage collector just makes Java less efficient at garbage collection through the RAM (See #82). Change that to -Xms512M (I personally use something like -Xms256M, as it will then have a ton of RAM to expand into).
     
  4. Offline

    uroskn

    Do you mean that it eats all RAM available to machine and then disk activity goes trough the roof (and server starts lagging)? Or server just silently crash (do you use swap on your server? If no, when you type in console 'dmesg', you should somwhere near the bottom see something similar to this: "Out of memory: Kill process 11230 (java) score 851 or sacrifice child")?

    In that case:
    Decrease ammount of RAM you allocate to bukkit. java will always eats up more than you've allocated to it (JVM overhead - it can in some cases be quite large!). try -Xmx2G, or even lower.

    You could also try to add -XX:MinHeapFreeRatio=1 -XX:MaxHeapFreeRatio=2 to your startup script. This will instruct java to take only as much RAM as it needs, at the cost of (slightly) increased CPU load. I don't know from top of my head if incremental garbage collector takes those two options, tough.

    CPU speed has nothing to do with how often GC is run. It does affect how much time it needs to do it's job, but that's normal. :)

    If java dies with java.lang.OutOfMemoryError, you have some plugin wich leaks shitton of memory. This should be evident in server.log. Update your plugins. I highly doubt this is the case, tough. ;-)
     
  5. Offline

    hackal

    Thank you guys for reply. I am not going to be on pc next 2 days, i will reply ASAP.
     
Thread Status:
Not open for further replies.

Share This Page