Assigning more RAM to a server GUIDE!

Discussion in 'Bukkit Help' started by InhumanSkills, Jan 21, 2011.

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

    InhumanSkills

    This guide is here to help you create and launch a Minecraft Craftbukkit server.
    I will be explaining how to do this on two operating systems. Windows and Linux
    I WILL NOT make a Mac Guide because I don't have a Mac! If someone has a guide I will add it.

    What you need to know!
    There are many ways to launch a server. I will be explaining two preferred ways that I use.

    In Windows I use a .bat File:

    What is a .bat file?
    A .bat file is just a launchable file that performs the task written within the file.

    First of all make sure you are using Notepad to edit the file.
    After you copied one of the texts below save it as "Launcher.bat" and it will automatically format it into a .bat file that you can use to launch CraftBukkit and later Bukkit.

    In Linux I use a .sh File that I launch through the Terminal:
    Read past Windows for a guide on Linux!


    ==========================================================
    ==========================================================

    Windows Guide:

    ==========================================================

    32 bit USERS PLEASE READ HERE

    The maximum amount of RAM you will be able to allocate for your 32bit Java is 1024M (1GB)!!!
    32 Java does recognize a maximum of 1536M (1.5GB) but will it will only use 1GB

    If you get this error


    "Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Could not create the Java virtual machine."

    You need to set it to -Xms1024M -Xmx1024M

    If this still fails your computer might not have enough RAM available.

    32bit .bat should look like

    -------------------------------------------------------------------------------------------------------------
    @Echo off
    "C:\Program Files\Java\jre7\bin\java.exe" -server -Xms1024M -Xmx1024M -jar craftbukkit-1.3.2-R1.0.jar
    pause
    -------------------------------------------------------------------------------------------------------------

    ==========================================================

    64 bit USERS PLEASE READ HERE

    Lucky you you have an awesome computer!!!
    You can change the -Xms1024M -Xmx1024M to whatever you would like!
    For optimal performance use whole intervals of 1024M (1GB)

    Examples:
    1GB = 1024
    2GB = 2048
    3GB = 3072
    4GB = 4096
    12GB=12288 <--- Thats me =D

    64 bit .bat should look like
    (This will reserve 4096M(4GB) of Ram for Java)

    -------------------------------------------------------------------------------------------------------------
    @Echo off
    "C:\Program Files\Java\jre7\bin\java.exe" -server -d64 -Xms1024M -Xmx4096M -jar craftbukkit-1.3.2-R1.0.jar
    pause
    -------------------------------------------------------------------------------------------------------------

    If you for some odd reason want to run your server on 32bit although you have 64bit use this path

    -------------------------------------------------------------------------------------------------------------
    @Echo off
    "C:\Program Files (x86)\Java\jre7\bin\java.exe" -server -Xms1024M -Xmx1024M -jar craftbukkit-1.3.2-R1.0.jar
    pause
    -------------------------------------------------------------------------------------------------------------

    ==========================================================

    The Green is the directory where you computer will look for the java to run your program. Java is usually located on your C: drive, in program files. Look inside the bin for "java.exe"
    You can see the location path by right clicking your java.exe, clicking properties, and looking at the security tab, it will be the object name.

    The Gray is the initial and maximum "heap" size. This is the amount of RAM you want to allocate for Minecaft. Also instead of " -Xms1024M " you can use " -Xincgc " which stands for incremental garbage collection. This will reduce the need for restarts.

    Please note that Java only takes whole GB increments so there is no point of making it 2560 (2.5Gb) because it will only use up to 2048(2GB).

    The Red is the .jar file you want java to execute. In this case it is "craftbukkit-1.3.2-R1.0.jar" you can rename the file to whatever you like but just make sure that the line in your .bat file has the same name as the file or you will get an error message telling you it could not be executed. "Unable to access jarfile craftbukkit.jar" Because you did not name it "craftbukkit-1.3.2-R1.0.jar". Also make sure to keep the .bat file in the same directory (folder) as your .jar otherwise it will not find it.

    Want to give you server a little boost?

    Go to your task manager (Ctrl-Shift-Esc), under processes find java.exe, right click it and under Set Priorities set it to Realtime. If it will not let you do this that is because you are not the administrator. To combat this simply click on "Show processes from all users" and try again.

    What this does it tells your computer that you think the Java program is important and thus your computer will focus on executing those tasks first. This might make other programs slower.

    Tired of Minecraft itself being too slow?

    javaw.exe is the Minecraft program itself, so the players on your server can set that to Realtime too.

    I have not seen a great improvement in performance when doing this but in theory it should help out the players on your server.

    ==========================================================
    ==========================================================

    Linux Guide:

    Firs of all I learned how to do this in one day! Please do not flame me if this is incorrect but this is what I did to get mine to work.

    Installing Java:
    If you have done this skip this step

    Go to System>Administration>Synaptic Package Manager
    It will prompt you for your password

    Once inside scroll down and find "Java Programming Language" not the (Universe) one
    Inside is a list of Java's you can install.
    You will want to check ia32-sun-java7-bin this should automatically also check
    sun-java7-bin and sun-java7-jre if these are not there you need to go to
    Settings>Repositories>Other Software and click Add
    Add:
    -------------------------------------------------------------------------------------------------------------
    or

    -------------------------------------------------------------------------------------------------------------

    Once done click Apply it should then install 32bit java.

    To get x64 bit Java go to:
    Applications>Accessories>Terminal
    Run "sudo apt-get install sun-java7-plugin"

    You might have to do some more tweaking to make this work. =/

    Launching the server:

    Change the directory before you do this!
    Create a folder on your Desktop and call it anything
    In Terminal type

    "cd /home/USER/Desktop/FOLDER"

    cd = change directory

    /home/USER/Desktop/FOLDER
    is the path for your new folder
    USER is your name and FOLDER is the name you made the folder


    You will need to create a .sh file to launch the server
    Go to the Terminal and run
    -------------------------------------------------------------------------------------------------------------
    vi "name".sh
    -------------------------------------------------------------------------------------------------------------
    "name" is what you want to name it, mine is "launcher.sh"

    vi commands are kinda confusing so it will take a little time to get used to it

    Simple vi commands:
    i (insert),
    dd (delete whole line)
    x (delete character)
    esc (stop current command)
    :w (write/save)
    :q ( quit)

    once you are in vi you will need to write this

    -------------------------------------------------------------------------------------------------------------
    #!/bin/sh
    "/usr/lib/jvm/java-7-sun/bin/java" -d64 -Xms1024 -Xmx1024 -jar craftbukkit.jar
    -------------------------------------------------------------------------------------------------------------

    The Green is the directory where you computer will look for the java to run your program.
    You can see the location by right clicking your java and looking at the Basic tab, it will be the Location. NOTE you need to add /java onto that location.

    The Gray is the initial and maximum "heap" size. This is the amount of RAM you want to allocate for Minecaft.

    Please note that Java only takes whole GB increments so there is no point of making it 2560 (2.5Gb) because it will only use upto 2048(2GB).

    The Red is the .jar file you want java to execute. In this case it is "craftbukkit.jar" you can rename the file to whatever you like but just make sure that the line in your .bat file has the same name or you will get an error message telling you it could not be executed. "Unable to access jarfile craftbukkit.jar" Because you did not match the names "craftbukkit.jar"

    To get out of vi press ":wq"

    You will now need to make the script executable
    got to the Terminal and type

    -------------------------------------------------------------------------------------------------------------
    chmod 755 "name".sh
    or
    chmod +x "name".sh
    -------------------------------------------------------------------------------------------------------------

    you can now go to the Terminal and type

    -------------------------------------------------------------------------------------------------------------
    ./"name".sh
    -------------------------------------------------------------------------------------------------------------

    this will launch the .sh file and hopefully your server
    =D

    ==========================================================
    ==========================================================

    If this guide has helped you please leave feedback on how I did.

    My service is to the community and your feedback will allow me to improve and expand this guide.

    Happy Crafting!

    ==========================================================
    ==========================================================
    Updated as of 10/15/12

     
  2. Offline

    InhumanSkills

  3. Offline

    Olas

    Great tutorial, although the process is similar, you may want to add instructions for linux as well.
     
  4. Offline

    ndm250

    tutorial for linux please!
     
  5. Offline

    Olas

    I may write a tutorial for Linux/CentOS (popular choice for VPS) unless someone beats me to it.
     
  6. Offline

    Hubbe King

    FYI, a good thing to do, since Minecraft server software has a lot of memory leaks,
    is to use the -Xincgc flag rather than assigning an -Xms value.

    Reduces RAM usage by a whole lot. Also reduces the need for server restarts.
     
    Hankscorpiouk likes this.
  7. Offline

    stolen_insanity


    What does this all mean?

    I've just upraded my PC to windows 7 ultimate x64
    I've allocated more RAM to my server than when I had x86
    My server now seems more laggy and I get this all the time:

    2011-01-26 22:22:20 [WARNING] Can't keep up! Did the system time change, or is t
    he server overloaded?

    I've put in 3072M and my PC has 6GB.
    It has and intel quad core also.
    Please help.
     
  8. Offline

    Tex©

    so i just tryied to incress the ram altoted to minecraft from 1gb to 4gb and i get this
    "Invalid initial heap size: -Xms4096M
    The specified size exceeds the maximum representable size.
    Could not create the Java virtual machine.
    Press any key to continue . . ."

    any ideas I am running win7 64bit and have 6gb DDR3
     
  9. Offline

    TnT Retired Staff

    What's the full command you ran?
     
  10. Offline

    Tex©

    Code:
    @ECHO OFF
    IF /I "%PROCESSOR_ARCHITECTURE:~-2%"=="64" "%ProgramFiles(x86)%\Java\jre6\bin\java.exe" -Xms4096M -Xmx4096 -jar "%~dp0craftbukkit-0.0.1.jar"
    IF /I "%PROCESSOR_ARCHITECTURE:~-2%"=="86" java -Xms1024M -Xms1024M -jar "%~dp0craftbukkit-0.0.1.jar"
    PAUSE
     
  11. Offline

    Hubbe King

    You are most likely using 32-bit java.
    Make sure the java variable points to "%ProgramFiles%\Java\jre6\bin\java.exe"
     
  12. Offline

    Tex©

    hurpdurp i didnt even see that lol
     
  13. Offline

    Hubbe King

    Also, the -Xincgc flag turns on Incremental GarbageCollect.
    This causes java to flush unused memory from allocation every few minutes, rather than let unused ram be allocated.
    (Unused ram being allocated is why bukkit, hMod and all Minecraft servers start using more and more ram as time passes. The -Xincgc helps prevent this. Thus reducing the need for restarts)

    Removing the -Xms flag isn't required for -Xincgc to work, but it is recommended, as -Xincgc replaces it anyway.
    (-Xincgc sets -Xms to be as small as possible, while still allowing the .jar to fully load.)
     
    Hankscorpiouk likes this.
  14. Offline

    Kawasaki

    I had tried to upgrade my server to 4GB from 1 GB but i get that message all the time.
    "Invalid initial heap size: -Xms4096M
    The specified size exceeds the maximum representable size.
    Could not create the Java virtual machine.
    Press any key to continue . . ."

    System: Server 2008 R2 64 bit
     
  15. Offline

    King_KYl3

    Im Wondering If i Give more RAM to My server will it Stop/degcrease Lag? Cuz im running it on 1GB Ram and i have 64 bit styem but only 2Gb ram and only 1.75 Usable Please help doe smore ram stop Lag Thanks?
     
  16. Offline

    1lann

    Not
    Yes and No. Depends on the amount of players, plugins and world size. But I would reccomend adding more ram anyway.
     
  17. Offline

    King_KYl3

    Hm f.e but it stops lag tho yer cuz i got good internet but i still lag :(
     
  18. Offline

    Semirotta

    what about if i use remotetoolkit for restart my server etc.
    Do i change something in my toolkit.bat ?

    my run.bat :
    @Echo OFF
    SET BINDIR=%~dp0
    CD /D "%BINDIR%"
    "%ProgramFiles%\Java\jre6\bin\java.exe" -Xms4096M -Xmx4096M -jar craftbukkit.jar nogui java
    pause

    and my toolkit.bat (the program which makes my restarts etc.):
    @Echo off
    java -Xmx30M -Xms30M -XX:MaxPermSize=40M -jar Minecraft_RKit.jar semirotta:*******

    do i need to change toolkit.bat things? thats 1 i start server with.
    my computer has 6GB RAM

    EDIT:
    it works only with 1024M..
     
  19. Offline

    Pencil


    Don't change that toolkit.bat! It's only the ammount you are giving the wrapper that runs around the bukkit wrapper. It will not give your actual server more ram. There is a config file for the rtoolkit thing that lets u set how much ram is used, the run.bat ain't even used AT all.
     
  20. Offline

    King_KYl3

    wat is a good amount of RAM to have cuz im going to buy some i have windows 7 compacq comp and only 1gb on server wats the good amount fot the server and hav no lag please repliy Thanks :D
     
  21. Offline

    1lann

    How many people?
     
  22. Offline

    Hagon94

    I am pretty sure my Awesome PC is 64 bit, so why is my run.bat already set on program files ( 86x) Wouldn't that mean 32 bit? I have a program files folder both normal, just " Program files" and one that says " Program files (86x) " .

    Did i install something in the wrong program files folder and mess up when making my run.bat in the first place? If so how do i fix this? :p

    Btw, will this give my server more capacity? Like, can i have more players online without lag now?
    Is this what this means?

    Also, i have only the standard ammount of ram ( 4gb).
    Would it be smart to assign 2gb of that to my minecraft server?

    Thanks :]

    OK, I moved the java folder over the Program files folder that is NOT (86x) and changed the run bat accordingly.
    I just tried to assign 2gb of ram to it and when i try to run the .bat file it just says:

    " Error occured during initialization of VM. Could not reserve enough space for object heap. Could not create the java virtual machine. Press any key to continue..."

    Any ideas on how to get past this?
    Nothing is EVER simple is it....

    EDIT:
    I tried with 1gb and that worked. So i guess i don't have enough RAM left to assign a whole 2gb to the server, huh? Or am i wrong here?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 6, 2016
  23. Offline

    Bad Science

    If Java's install files were in the x86 folder, then you don't have 64 bit Java. Move the Java folder back to where it was and completely uninstall Java, if there are multiple versions of Java in add/remove programs get rid of them all. Get Java 1.7 64 bit here http://www.java.net/download/jdk7/a...dk-7-fcs-bin-b146-windows-x64-20_jun_2011.exe and install it and you should be good as long as you didn't mess anything up while moving files around.

    BTW, does "Awesome PC" refer to something specific?



    EDIT: Sorry, I should tell you that's only a dev snapshot, but I'm using the same build without issues and getting better performance than 1.6.
     
  24. Offline

    Hagon94

    Well, no. The " Awesome PC" thing is nothing ^_^ I just like my PC. It's fairly beefy, but has the standard amount of ram needed for gaming.

    Also, thanks for the tip :D
    I'll try that!
     
  25. Offline

    InhumanSkills

    sorry i haven't been replying in a while. I got a new job and i kinda put minecraft to the side. If you want anything don't hesitate to pm me.
     
  26. Offline

    Costan Balgobin

    Ive folowed the -Xincgc thing. Does anyone know any other small ways to make server performance greater?
     
  27. Offline

    King_KYl3

    Please help wat should numbs i write if i want 7GB to server ? thanks :D
     
  28. Offline

    Viloresi

    thanks for this! but how can i change from java 32 bit at java 64 bit? I have a 64 bit system
     
  29. Offline

    zaphodx

    Get internet explorer 64bit, download java jre7 for 64bit. Then use the instructions in the OP's post

    P.S. Thanks OP, worked perfectly and very easy to understand, thank you.
     
  30. Offline

    harrisonduell

    Does anyone know how i can get more ram?
     
Thread Status:
Not open for further replies.

Share This Page