The Meaning of Life, the Universe, and Everything.
Join Date:
12/6/2014
Posts:
54
Member Details
If you've had crashes after crashes occur in your Minecraft install and have allocated tons of Memory to MC, this may be the thread to read.
It's become pretty common advice in many circles of the internet to increase the amount of Memory Minecraft can use via the -Xmx argument. To put it simply, this is in many cases poor advice, especially for users with lots of mods and/or very limited hardware resources.
Minecraft's system of loading objects into memory doesn't quite work as expected. If you fly away from a chunk, and it stops rendering or updating mobs, you have every reason to believe that that chunk has been unloaded from memory, but it hasn't.
You see, Minecraft has left that information cached in memory, taking up your RAM which could be used on other applications or new chunks. But, to keep this memory from leaking and causing crashes, Java has something called a garbage collector, which activates once the memory buffer(set previously by the -Xmx argument) gets full. This garbage collector eats up CPU resources depending on how much memory it needs to clear, but doesn't operate under normal circumstances until the buffer is filled.
This can result in massive lag and crashes; while increasing the RAM ceiling for Minecraft at first can seem like a good idea, and will even increase FPS for quite a while, once the garbage collector is called upon, it has a lot of work to do. It stops new chunks from loading for however long it needs and eats up your CPU, causing the internal server to halt for quite a long while.
This problem is mitigated by leaving the garbage collector with less work to do; if you lower your Minecraft install from using 4gb of RAM to, say, 1gb, the garbage collector will run significantly more often, but it wont consume so much time, resulting in more frequent lag spikes and framerate drops, but a full stop to the frequent crashes experienced when Minecraft's memory buffer gets too bloated.
In other words, depending on the strength of your CPU's individual cores, it is often more wise to starve Minecraft of RAM than to bloat it, since it allows for more exploration and longer play sessions, but with a lag spike here and there. To boot, it will even let you do more in the background of your Minecraft game like listening to music or looking things up on wikis, and even make your computer run cooler!
The solution is often unintuitive, but rather than simply giving Minecraft as much memory as you can, it's really a game of balancing between the amount and power of lag spikes. Do you want more lag spikes which only last a few ticks, or one lag spike every half hour which seems to crash Minecraft entirely? For the former, allocate less memory(ie, Xmx512m) and for the latter, allocate more(ie, Xmx2048m).
Ideally, Minecraft should unload chunks and other data it's currently not using automatically, but as long as it doesn't, being wise about your memory management for MC is the best thing you can do to mitigate performance issues.
Thanks for the advice! many websites told me to up it to 2Gs but then my cpu is working like 90-100% for nothing! So I changed it to 1G (was originally 512M). And my minecraft has better lagspike rates!
Rollback Post to RevisionRollBack
There are 10 types of people in the world. Those that understand binary and those that don't.
Thanks for the advice! many websites told me to up it to 2Gs but then my cpu is working like 90-100% for nothing! So I changed it to 1G (was originally 512M). And my minecraft has better lagspike rates!
You're welcome! ^.^
And yeah, it's all about finding a balance between the frequency and power of your lag spikes.
Most games, when they don't need content in memory, simply unload the data, but Minecraft(and I'm tempted to say Java in general, if the coder doesn't run frequent garbage collection) will eat up all of the memory it can with massive, useless data caches.
The thing with running a server is that you need to allocate varying levels of memory depending on how many players are in your game, because more players means more loaded chunks and more memory actually being used, which can, of course, throw the classic out of memory errors.
Many public server owners just bloat Minecraft of RAM and then set the server to re-boot periodically. But this can be avoided by using the incremental garbage collector, a less reliable, more performance hungry version of the garbage collector that runs constantly rather than just waiting for the memory cache to get full. In theory, it should be able to handle large numbers of players without needing a reboot, keeping it from having to do massive amounts of work occasionally while avoiding the out of memory error, but your server will need a pretty solid CPU to keep that from causing constant lag spikes of doom.
Thank you for clarifying this. I keep on trying to explain to people that moving MC to C++ might not be a good idea because of Garbage Collector, which C++ lacks.
Thank you for clarifying this. I keep on trying to explain to people that moving MC to C++ might not be a good idea because of Garbage Collector, which C++ lacks.
One thing I've never understood is why it's common practice among Java coders to keep data cached in memory. In pretty much any other circles, that would be called a memory leak. The GC is a bandaid fix for memory leaking, but it destroys performance and eats up massive amounts of CPU.
Is there some actual reason why it's common practice to leave data hanging in memory like this? Because I can't think of any good reasons for it outside of lazy programming.
You can't actually delete an object in Java, you have to wait for the garbage collector to run (you can manually invoke the garbage collector however).
One thing I've never understood is why it's common practice among Java coders to keep data cached in memory. In pretty much any other circles, that would be called a memory leak.
I'd say the difference is this: a data cache can be flushed if it gets too big, but a memory leak cannot.
There are other sites that go into headache-inducing detail about how Java garbage collection works (e.g. http://www.dynatrace.com/en/javabook/how-garbage-collection-works.html), but your post is fairly simple - I was giving Minecraft 6144 MB, which is probably more than it needs, even with multiple mods, resource packs, and shaders. 1024 MB wasn't enough for me, but now I'm gradually increasing the allocation by 256 MB at a time until I find the right amount.
Edit: 2560 MB seems to be the sweet spot for my current list of mods and resource packs. However, I'm planning to start a new world soon with more mods, which might need a bit more memory.
If you've had crashes after crashes occur in your Minecraft install and have allocated tons of Memory to MC, this may be the thread to read.
It's become pretty common advice in many circles of the internet to increase the amount of Memory Minecraft can use via the -Xmx argument. To put it simply, this is in many cases poor advice, especially for users with lots of mods and/or very limited hardware resources.
Minecraft's system of loading objects into memory doesn't quite work as expected. If you fly away from a chunk, and it stops rendering or updating mobs, you have every reason to believe that that chunk has been unloaded from memory, but it hasn't.
You see, Minecraft has left that information cached in memory, taking up your RAM which could be used on other applications or new chunks. But, to keep this memory from leaking and causing crashes, Java has something called a garbage collector, which activates once the memory buffer(set previously by the -Xmx argument) gets full. This garbage collector eats up CPU resources depending on how much memory it needs to clear, but doesn't operate under normal circumstances until the buffer is filled.
This can result in massive lag and crashes; while increasing the RAM ceiling for Minecraft at first can seem like a good idea, and will even increase FPS for quite a while, once the garbage collector is called upon, it has a lot of work to do. It stops new chunks from loading for however long it needs and eats up your CPU, causing the internal server to halt for quite a long while.
This problem is mitigated by leaving the garbage collector with less work to do; if you lower your Minecraft install from using 4gb of RAM to, say, 1gb, the garbage collector will run significantly more often, but it wont consume so much time, resulting in more frequent lag spikes and framerate drops, but a full stop to the frequent crashes experienced when Minecraft's memory buffer gets too bloated.
In other words, depending on the strength of your CPU's individual cores, it is often more wise to starve Minecraft of RAM than to bloat it, since it allows for more exploration and longer play sessions, but with a lag spike here and there. To boot, it will even let you do more in the background of your Minecraft game like listening to music or looking things up on wikis, and even make your computer run cooler!
The solution is often unintuitive, but rather than simply giving Minecraft as much memory as you can, it's really a game of balancing between the amount and power of lag spikes. Do you want more lag spikes which only last a few ticks, or one lag spike every half hour which seems to crash Minecraft entirely? For the former, allocate less memory(ie, Xmx512m) and for the latter, allocate more(ie, Xmx2048m).
Ideally, Minecraft should unload chunks and other data it's currently not using automatically, but as long as it doesn't, being wise about your memory management for MC is the best thing you can do to mitigate performance issues.
Thanks for the advice! many websites told me to up it to 2Gs but then my cpu is working like 90-100% for nothing! So I changed it to 1G (was originally 512M). And my minecraft has better lagspike rates!
There are 10 types of people in the world. Those that understand binary and those that don't.
http://www.minecraftforum.net/forums/mapping-and-modding/resource-packs/2128869-1-9-15w35b-ragecraft-faithful-64x64
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1293018-opencomputers-v1-5-16
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1272467-flans-mod-5-0-apocalypse-1-0-helicopters-mechas
You're welcome! ^.^
And yeah, it's all about finding a balance between the frequency and power of your lag spikes.
Most games, when they don't need content in memory, simply unload the data, but Minecraft(and I'm tempted to say Java in general, if the coder doesn't run frequent garbage collection) will eat up all of the memory it can with massive, useless data caches.
The thing with running a server is that you need to allocate varying levels of memory depending on how many players are in your game, because more players means more loaded chunks and more memory actually being used, which can, of course, throw the classic out of memory errors.
Many public server owners just bloat Minecraft of RAM and then set the server to re-boot periodically. But this can be avoided by using the incremental garbage collector, a less reliable, more performance hungry version of the garbage collector that runs constantly rather than just waiting for the memory cache to get full. In theory, it should be able to handle large numbers of players without needing a reboot, keeping it from having to do massive amounts of work occasionally while avoiding the out of memory error, but your server will need a pretty solid CPU to keep that from causing constant lag spikes of doom.
Accidental multi-post. Nothing to see here, ladies and gentlemen.
Thank you for clarifying this. I keep on trying to explain to people that moving MC to C++ might not be a good idea because of Garbage Collector, which C++ lacks.
One thing I've never understood is why it's common practice among Java coders to keep data cached in memory. In pretty much any other circles, that would be called a memory leak. The GC is a bandaid fix for memory leaking, but it destroys performance and eats up massive amounts of CPU.
Is there some actual reason why it's common practice to leave data hanging in memory like this? Because I can't think of any good reasons for it outside of lazy programming.
You can't actually delete an object in Java, you have to wait for the garbage collector to run (you can manually invoke the garbage collector however).
I'd say the difference is this: a data cache can be flushed if it gets too big, but a memory leak cannot.
There are other sites that go into headache-inducing detail about how Java garbage collection works (e.g. http://www.dynatrace.com/en/javabook/how-garbage-collection-works.html), but your post is fairly simple - I was giving Minecraft 6144 MB, which is probably more than it needs, even with multiple mods, resource packs, and shaders. 1024 MB wasn't enough for me, but now I'm gradually increasing the allocation by 256 MB at a time until I find the right amount.
Edit: 2560 MB seems to be the sweet spot for my current list of mods and resource packs. However, I'm planning to start a new world soon with more mods, which might need a bit more memory.
Can someone here tell me how to get my old jvm since I start to crash with mods,or at least what is the jvm argument on a 4gb ram pc