How do you allocate more RAM to Minecraft?
There is a lot of lag when I play Minecraft. I think this is due to the low amount of RAM I've allocated to Minecraft. (495MB)
How do you allocate more RAM to Minecraft?
I checked my other computer (Intel i5 Core) and it had the same amount of RAM allocated to Minecraft. However, Minecraft did not lag on that computer.
After I installed Optifine on this computer, the lag stopped (I don't know why cause I read that Optifine splits the load onto 2 cores, but I have only one core (At least I think so, a sticker on the laptop says Intel CORE i7)).
58 Answers
Before you allocate RAM there are some things you should know:
- x64 systems can allocate up to 192GB when using Windows Professional or above. 16GB when using Windows Home Premium and 8GB when using Home Premium and Starter. Also, please be aware of the physical limits imposed by your CPU Architecture.
- x32 systems can allocate up to 1GB (This is from personal experience on a 8GB machine and a 3GB machine, please correct me if I'm wrong)
So it is recommended you have a x64 system to allocate as much RAM as possible. Try an leave at least 1GB for the general system processes and stuff like that.
Here is how you allocate RAM on a windows system:
- Create a new document and save it as
run.bat - Type the following this is for 4GB:
C:\<location to your javaw>\javaw.exe -Xmx4096M -Xms2048M -jar <location of your Minecraft exe>So basically, the xmx is your maximum RAM your allocating and your xms is the minimum ram it should use.
Here is an example of an actual run.bat:
"C:\Program Files\java\bin\javaw.exe" -Xmx4096 -Xms2048 -jar "C:\users\user\Desktop\minecraft.exe"Or if you have assigned Java in your system variables
javaw -Xmx4096 -Xms2048 -jar "C:\users\user\Desktop\minecraft.exe"Obviously don't just copy my code, as you need to find out where A) Your javaw.exe is located and B) where your minecraft.exe
Remember: 1GB = 1024MB and 0.5GB = 512MB
Old Launcher Introduced in 1.6
With the new launcher, it is allot easier to allocate RAM to your Minecraft. Simply go ahead and edit a profile and where it says "Java Settings (Advanced)", tick all the check boxes. Then add the amount of RAM you would like to the JVM Arguments text box. For example if I wanted to run it with 1GB I would simply type -Xmx1G and the 1G will indicate 1GB of RAM. xmx indicates the maximum RAM to allocate.
Ensure that you have the correct path to your java and that you have JDK installed.
Latest Launcher
In the latest launcher, if you go to the "installations" tab, go to the edit installation settings for that particular version, scroll down and select more options, you're able to change the max amount of RAM by simply changing the -Xmx parameter.
ALTERNATIVELY
Simply download the tekkit pack and there is an option to play vanilla Minecraft. Simply select the "Cog" or settings icon in the top right corner and it will give you an option to allocate RAM if other methods are failing. Good Luck
Also if you are having trouble doing any of this, just simply google it and there are literally 100s of posts similar to this and allot of tutorials.
12It is explained in full by this video (and the following text was found here with edits as found in the comments).
In essence this video denotes 3 main steps:
Moving Minecraft to a folder. (Make sure this is the actual minecraft.exe and not a shortcut)
Creating a text file using note pad, and write out (this example is for 2GB of RAM):
java -Xmx2048M -Xms1048M -jar “minecraft.exe” Note: If you are experiencing issues with this when running Windows 8 try deleting the quotation marks around Minecraft.exe. Alternatively, try and switch java to javaw instead. Credit to “Anon” in the comments!
- Save this file as a .bat and store it in the same file which you store Minecraft.exe.
Note: this example uses 2GB of RAM, for more or less RAM add intervals of 1024 for each additional GB.
5This is how my .bat file looks like in the MC folder:
start /high javaw -Xms2048m -Xmx4096m -jar minecraft.exe
If this gives you an error as well then you might want to download the java SDK, it gives more functionality.
Running the bat as administrator might help too.
5- Go to control panel
- Search Java
- Click on Java
- Click on Java at the top
- Click view
- You will see something like this:
-Xmx2048m - Click on that then backspace until it looks like this:
-Xmx - Now add your desired amount of RAM in Mb, then an
mit should look something like-Xmx4096m(when you set it to 4GB)
Here's an example of direct optimization through .bat file
start javaw -Xms4096K -Xss128M -Xmx2048M -XX:PermSize=24m -XX:MaxPermSize=32m -XX:+UseParallelOldGC -XX:ParallelGCThreads=4 -XX:+CMSIncrementalPacing -XX:+AggressiveOpts -XX:+UseThreadPriorities -XX:+UseFastAccessorMethods -XX:+UseBiasedLocking -XX:+UseStringCache -XX:+TieredCompilation -XX:SurvivorRatio=8 -Dsun.java2d.noddraw=true -Dsun.java2d.d3d=false -Dsun.java2d.opengl=true -jar Spoutcraft-Launcher.jarThis one is for spoutcraft but you can just replace it on minecraft launcher's exe name and be done with it. If something goes wrong you can probably remove biased locking and string cache, along with tiered compilation and also setup parallelGCThreads to be equal your amount of cores.
Do you need to allocate more RAM? Often the default heap size is fine for your machine. Minecraft is unusual because it tends to be CPU-bound rather than GPU- and memory-bound. But it is possible your Java heap is too small.
To determine whether your Java heap is big enough:
- Open Minecraft and launch any world.
- Show the debug screen (press F3).
- In the top right corner, look for a line that says "Mem: X% Y/Z MB." X and Y will be constantly increasing. Z will generally not change much, but see the next line.
- The line below that will say "Allocated: W% Z MB"; if this remains less than 100% after you play for a while, that means Java is not using its maximum heap size. This is rather unusual, but it may mean you are not under serious memory pressure (i.e. you don't need a bigger heap), or it may simply mean that Java is not good at figuring out how big its heap should be. This cannot happen if you're using the
-Xmsand-Xmxoptions described in other answers, since they force the minimum and maximum heap sizes to be the same. - Play for a while, until the "Mem" line has reached 100% and gone down a few times. This is called "garbage collection," and indicates that the Java runtime is reclaiming memory which the application (Minecraft) is no longer using. Pay attention to how often this happens.
- If it's happening very frequently (e.g. once a second) or you see the percentage constantly oscillating near 100%, you probably don't have enough memory on Java's heap. If it does not happen very often, but you see lag when it does, your collection runs are too slow. Adding more memory may help with this to a point, since it allows for better generational garbage collection (only collecting some of the dead memory some of the time). However, there are diminishing returns here, and you may need a better CPU if you continue to observe this behavior after adjusting the heap. In this case, you might also experiment with
-XgcPrio:pausetime, but YMMV on whether that accomplishes anything whatsoever.
As a rule of thumb, do not make the heap bigger than your actual physical RAM. You will just cause the application to begin swapping or paging.
Create a .bat file. This is how mine looks:
javaw -Xmx4096 -Xms2048 -jar "C:\Users\nope\Desktop\minecraft.exe"(The reason why the nope is in there is that my computer's account name is "nope".)
The -Xmx4096 and -Xms2048 are what allocate more memory to Java (and therefore to Minecraft). Mine set the maximum to 4096MB (4GB) and the starting allocation to 2048MB (2GB), and you can allocate more or less by changing those numbers in the command.
It's worth noting at this point that as of version 1.6 and on the launcher has changed and there is now a new (arguably easier) way to allocate more memory to Minecraft.
You can do this by:
- Opening up the Minecraft launcher.
- Clicking the "Edit Profile..." button at the bottom left.
- Ticking the JVM Arguments box at the bottom of the menu.
- Changing the value of -Xmx1G, where 1G already equals 1GB of RAM.