Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

Allowing Java more RAM?


  • Please log in to reply
29 replies to this topic

#1

OrWhatever

Posted 01 November 2010 - 10:27 AM

I have this problem, where if I set render distance to "Far" Java exceeds 1GB of RAM on anything other than a regular old map. I used to be able to get around this by just scrapping any snow map I got when generating, but with biomes this is not a valid solution. The problem is that when Java does this, it stops working: It freezes and Windows tells gives me an error message. I'm pretty sure it's because either 1) Java is only allowed 1GB of RAM and does not do a dump automatically when it's reaching this limit or 2) because the engine is programmed specifically to only handle this much.

Therefore I ask you: Am I the only one experiencing this problem? And is there any way in which I can allow or force Java to use more RAM?
Roar's Kingdom - A village RP-lite server.

Register or log in to remove.

#2

Uberubert

Posted 01 November 2010 - 10:35 AM

How much ram do you have available?
Are you using Vista? Win6? XP? Linux? MacOS?

#3

OrWhatever

Posted 01 November 2010 - 10:51 AM

6GB of DDR3 RAM available. Windows itself uses about 15%, so there's more than enough RAM available. OS is Windows 7 Ultimate x64.
Roar's Kingdom - A village RP-lite server.

#4

Uberubert

Posted 01 November 2010 - 11:11 AM

I have the same setup, same OS, but can't seem to make it use more than 1 115 000 KB memory.
Far fog setting, running around exploring even during nighttime, I see memory climb steadily. At around the 1mill mark, I hear the systemdisk working slightly (pagefile, perhaps).

Silly idea: Is your pagefile by any chance disabled?
Another idea: Completely uninstall java, then re-install it.
Simpler idea: Does this happen on only one specific world, or on any world?

#5

Ultrapig
    Ultrapig

    Tree Puncher

  • Members
  • 15 posts

Posted 01 November 2010 - 11:23 AM

Java lets you tell it how much RAM to use. By default on most PCs it would use 256MB, but the Minecraft launchers sets it to 1GB. Normally you set the heap size (as it is called in Java) like so: java -Xmx2048M -jar Minecraft.jar
That would set the heap to 2GB. Unfortunately that only sets the heap size for the launcher. That then starts another process with different options, and unless Notch changes the launcher there is no way to pass other options through.

#6

PMental
    PMental

    Lapis Lazuli Collector

  • Members
  • 934 posts
  • Location: Sweden
  • Minecraft: PMental

Posted 01 November 2010 - 11:48 AM

Ultrapig said:

unless Notch changes the launcher there is no way to pass other options through.
Am I missing something or isn't that essentially what this string does?
java -Xmx1024M -Xms512M -cp Minecraft.jar
Except raise the numbers appropriately of course...

It's basically how you launch in Linux, but it should work in Windows as well I think? Haven't tried it since my game runs fine so far btw.
Be sure to check out my  Youtube channel for Fireworks (autofiring/autoloading), many minecart inventions, my "Chicken Machine" (breeding, egg farm and cooking) and many more inventions. In HD, new uploads every week.

#7

Ultrapig
    Ultrapig

    Tree Puncher

  • Members
  • 15 posts

Posted 01 November 2010 - 12:02 PM

Minecraft uses a "launcher" class which doesn't do anything except create another process which is the actual game. You can see this by the way the command line immediately returns when you run the command. The child process created by the launcher doesn't inherit any Java options from the launcher.

#8

PMental
    PMental

    Lapis Lazuli Collector

  • Members
  • 934 posts
  • Location: Sweden
  • Minecraft: PMental

Posted 01 November 2010 - 01:44 PM

Well, unless I'm missing something, that wasn't too hard after all!

Just running Minecraft.exe, notice memory allocated and used.
Posted Image

Running with custom Java command line.
Posted Image

EDIT: As a bonus I noticed that Minecraft is fully playable on my laptop at work. SHIT...
Be sure to check out my  Youtube channel for Fireworks (autofiring/autoloading), many minecart inventions, my "Chicken Machine" (breeding, egg farm and cooking) and many more inventions. In HD, new uploads every week.

#9

TopUSGun
    TopUSGun

    Tree Puncher

  • Members
  • 34 posts

Posted 01 November 2010 - 01:59 PM

PMental said:

Well, unless I'm missing something, that wasn't too hard after all!

Just running Minecraft.exe, notice memory allocated and used.
Posted Image

Running with custom Java command line.
Posted Image

EDIT: As a bonus I noticed that Minecraft is fully playable on my laptop at work. SHIT...

Are you using this

Quote

java -Xmx1024M -Xms512M -cp Minecraft.jar
?

Posted Image
Posted Image
Posted Image


#10

PMental
    PMental

    Lapis Lazuli Collector

  • Members
  • 934 posts
  • Location: Sweden
  • Minecraft: PMental

Posted 01 November 2010 - 02:03 PM

Err, sorry, forgot the command line! Nope, that one won't work at all, I used this one:
javaw -Xmx1536m -Xms768m -jar "C:\Minecraft\Minecraft.exe"
Except you replace the path to point at your own minecraft.exe obviously.

Just running the exe is equivalent to this:
javaw -Xmx1024m -Xms512m -jar "C:\Minecraft\Minecraft.exe"

If you have 4Gb+ you can probably double that.

Not sure how it affects performance, but it cannot hurt to try...
Be sure to check out my  Youtube channel for Fireworks (autofiring/autoloading), many minecart inventions, my "Chicken Machine" (breeding, egg farm and cooking) and many more inventions. In HD, new uploads every week.

#11

ArticTiger

Posted 01 November 2010 - 02:12 PM

Minecraft.exe being the launcher you get from the site right?
Posted Image
Click the sig

#12

WarhawkXeroFire

Posted 01 November 2010 - 02:25 PM

http://www.minecraft...hp?f=35&t=60838

Check it out, if your using the Windows Launcher. Basically, the exe we use is only a wrapper. You can pass variables to the executable through a config file placed in the same directory as your Minecraft exe. Problem is, you can only designate a max of 1/4 of your RAM, minus operating system usage. This is a Java thing...

For instance, I use 8GB of DDR2-1066. The max I could designate without slowdowns or crashing was 1350M, or 1.35GB. That little bit helped so much though, as I got no more stuttering, freezes, etc... not sure why, but it helped.

#13

Ultrapig
    Ultrapig

    Tree Puncher

  • Members
  • 15 posts

Posted 01 November 2010 - 02:37 PM

Hmm, this seems to behave differently under Windows and Linux.

If you are having pauses with a large heap size you could try using -XX:+UseConcMarkSweepGC which selects a concurrent garbage collector.

I am going to see if I can get it to use the server VM on Windows, as that should have a very good effect on performance.

#14

Ultrapig
    Ultrapig

    Tree Puncher

  • Members
  • 15 posts

Posted 01 November 2010 - 02:41 PM

WarhawkXeroFire said:

Problem is, you can only designate a max of 1/4 of your RAM, minus operating system usage. This is a Java thing...
I wouldn't say "this is a Java thing". I assume that you are on a 64bit OS given the amount of RAM you have, so you should be able to uses many GBs without trouble. Though GC pauses can have an effect with larger heap sizes. The CMS GC option I mentioned in the previous post might help. Also on 64bit systems you can try -XX:+UseCompressedOops

#15

WarhawkXeroFire

Posted 01 November 2010 - 03:11 PM

Hmm, didn't know about GC. I tried setting my RAM to about 1.75Gb, but I would get horrendous freezing just trying to load the launcher. From what I was gathering from other threads about the issue was that the RAM issue was a Java problem, but no one could provide a reason as to why. I did try using a full 2GB at one point, but kept getting some error when trying to launch Minecraft - wasnt a MC error, but a JavaW error.

Once I get out of this programming class in 30 minutes, I will test your suggestion and post back with results.

#16

PMental
    PMental

    Lapis Lazuli Collector

  • Members
  • 934 posts
  • Location: Sweden
  • Minecraft: PMental

Posted 01 November 2010 - 03:24 PM

The 1/4 of RAM doesn't apply to my computer, I have 2GB of RAM but get flawless performance with the default setting of 1024Mb max, provided I have that much free of course as disk swapping will kill any performance.

Not the same computer as used in the test above btw. I think I may have to bring some more RAM home from work and play a bit with the settings tonight maybe.

Good find on the .ini btw, that's a nicer way of doing it than making a shortcut to javaw. I'll probably do it from the command line while experimenting though.
Be sure to check out my  Youtube channel for Fireworks (autofiring/autoloading), many minecart inventions, my "Chicken Machine" (breeding, egg farm and cooking) and many more inventions. In HD, new uploads every week.

#17

Ultrapig
    Ultrapig

    Tree Puncher

  • Members
  • 15 posts

Posted 01 November 2010 - 03:47 PM

Right, I have figured out that the Minecraft launcher behaves differently when the heap size is set. If it is too low then it launches another process which is why I couldn't change system properties before.

Be careful increasing the heap size if you have integrated graphics (particularly Intel): it can make the drivers crap out.

If Minecraft is slow instantly with a large heap size then I would guess the OS is swapping immediately. Are you sure you have all that RAM? And you are on a 64 bit OS? Actually maybe you have a 32bit JRE. That would explain why you can't go above 2GB. You can get a 64bit version at java.sun.com.

I got Minecraft to run with the server VM. For those who are not familiar with Java there are two "internal" versions of Hotspot: client and server (or C1 and C2). Client starts faster but doesn't optimize as much. Server takes a bit longer to start but can perform much, much better for long running applications. You turn on the server vm by adding -server to the command line. Unfortunately on Windows the JRE only comes with the client VM. To enable it you need to download and install the JDK (it is the Java development kit), go to C:\Program Files\Java\jdk1.6.0_22\jre\bin (or Vista/7 equivalent) and copy the server folder to C:\Program Files\Java\jre6\bin

It has the potential to help a lot if you are CPU bound. If you have crappy integrated graphics then it won't do much.

#18

PMental
    PMental

    Lapis Lazuli Collector

  • Members
  • 934 posts
  • Location: Sweden
  • Minecraft: PMental

Posted 01 November 2010 - 03:56 PM

Ultrapig said:

Actually maybe you have a 32bit JRE. That would explain why you can't go above 2GB. You can get a 64bit version at java.sun.com.
That's one well worth checking out. When I started looking at my Java environment because of some small performance issues with Minecraft I noticed I was running 32-bit Java only. Now running 64-bit.

Does anyone know if running 64-bit Java in itself would help performance (memory issues aside), like in more efficient running of the code or something to that extent? Or is that dependant on Notch also doing something with his code?

EDIT: Good info in general btw, will have to check some of this out. I already have the SDK installed.
Be sure to check out my  Youtube channel for Fireworks (autofiring/autoloading), many minecart inventions, my "Chicken Machine" (breeding, egg farm and cooking) and many more inventions. In HD, new uploads every week.

#19

WarhawkXeroFire

Posted 01 November 2010 - 04:13 PM

Huh, didnt even notice that I am using Java 32bit - slightly annoying. Updating now, will post results lol. I know I said I would before, but didn't even cross my mind there, since the standard java installer never gave me the option, thus making me think it auto-detects, as with some software.

Give you an idea on my system, since I was getting oddly bad performance before increasing the memory...

AMD Phenom II 940 BE @ 3.2GHz w/ CoolerMaster V6 cooler
Gigabyte GA-MA790X-UD4
8GB OCZ Reaper HPC DDR2-1066
Sapphire HD5850 Toxic @ 800/1200
SoundBlaster X-Fi Fatal1ty Pro
CoolerMaster 700w Ultimate UCP
CoolerMaster CM690

#20

Ultrapig
    Ultrapig

    Tree Puncher

  • Members
  • 15 posts

Posted 01 November 2010 - 04:17 PM

x86 64 bit processors have a lot more registers available (x86 has very few registers compared to pretty much any architecture) which is the biggest performance advantage for 64 bit. 64 bit Java will take advantage of this automatically. There is a downside that pointers are now twice as big so you use more memory. In Java this can be avoided by using -XX:+UseCompressedOops, which does some extra work to make it possible to store pointers in 32 bits. Be aware that there have been many JVM bugs with this option.