Good morning, recently I have been having some problems with Minecraft and the use of ram, every time I try to play a minecraft modpack, in any version and any mods, it always uses the maximum allocated ram and a little more, for example, I allocate 4gb, minecraft ALWAYS uses 6.5gb, I can be on the loading screen or in the game, always the same amount. I have 16gb of memory, so the problem is when I play very heavy modpacks and I allocate 8gb ram, it always uses 10gb of ram, and sometimes I have freezes. I've tried to reinstall java, use multiple arguments and multiple clients until the original minecraft, but the error persists. In the game the usage is shown normally, however, in the task manager it is always more than allocated.
The problem is the game shows 3gb of ram use and the task manager shows 10gb and never down!
Now I'm using multimc and it shows the same, i don't know what to do.
This is normal, and is why you should never allocate more than half your free memory to the game (more or less, the overhead is relatively constant, about 2-2.5 GB from what you say); not only can you force your system to page to disk, which will cause lag spikes, but garbage collection will also take longer, again causing lag spikes (or more noticeable/longer spikes, ideally they are short enough to not be noticeable):
2. Why not give it more memory?
Let's give Minecraft 4 GB of RAM to play with. This would need a PC with at least 8 GB RAM (as the real memory usage is almost double the memory visible in Java). If the VM decides to use all the memory, then it will increase the time between the garbage collections (20 sec instead of 4), but it will also increase the garbage collection time by 4, so every 20 seconds there will be one massive lag spike.
This also explains why you shouldn't allocate as much memory as you feel like; if the memory usage (in F3) only goes to say, 3 GB then 4 GB should be enough.
Also, what are your JVM arguments? Do you have -Xms or just -Xmx? -Xms will force the JVM to use all the memory available if it is equal to -Xmx, even if it isn't needed (if you do use it it shouldn't be any higher than the normal memory usage; the main benefit is during startup, as otherwise the JVM will resize the heap multiple times, slowing it down).
That thread may be of use to you. What you allocate to it isn't the total limit of what the entirety of Minecraft can and will use; it will be more. However, such high use wasn't normal, though it happened more than once, as well. I only had it actually get to 10 GB and complain of actually being out of memory that once though, and I then raised my page file, which is what I suspect was the issue, so make sure you're not disabling it (do NOT do this) and if you're setting a smaller static size than what Windows usually defaults to, with today's programs and RAM amounts, make sure it's still enough.
I've saw about that and i don't allocate more than 8gb ram, but the problem are in minecraft ALWAYS use max ram allocated and more, if i allocate 3gb, the game will use 4/5gb all the time, creating a world or playing in other dimension, the ram never changes and stay on more than max.
I'm don't using any argument, in the multimc i say to allocate 512 to minimun memory and 8096 to max.
Well, I can't say what's going on unless it's pre-caching or something. The old statement is "unused RAM is wasted RAM" so maybe it's using up to the limit regardless of the minimum it needs. I'm not sure.
Regardless, the question then becomes "is this a problem to you?" If you need it use less RAM, allocate less. If it's enough, then all is well and allocate less. If it's not enough, you don't have enough RAM then.
Is the freezing lasting multiple seconds while reflecting maximum RAM use, only to drop after the garbage collector saves it from a crash? Or is it more like stutter or micro stutter?
If it's the first one, that is strange, and I've got no answers for it. The obvious answer would be "raise your RAM allocation" but you say Minecraft chases the amount you set, whether it's increased or decreased, and then behaves this same way (freezing from being at max RAM use) regardless? Yeah, that is strange.
Does this also happen with vanilla, or only when running all of those mods? Start there to see if it's an issue with the game, or maybe a memory leak with one of the mods.
Stutter during garbage collection is normal; the severity of it varies though.
You've identified RAM use is higher with mod packs with hundred of mods. That is normal too.
You need to find out if you simply need to allocated even more RAM (if you have 16 GB, I'd caution against allocating more than 8 GB), or if there is a particular bad mod or few causing runaway RAM use. Unfortunately, that is beyond my knowledge. You might just need more RAM and RAM allocation for that mod pack.
go in 5:33, see the use of ram in minecraft and in task manager, that's the problem, my minecraft is ALWAYS using more than allocated ram, even if I allocate 4gb it will use 9gb.
As I've mentioned before, the memory allocated to a Java application (using -Xmx) is only a portion of the total memory used by the entire Java process, which can be thought of like running a Windows VM on Linux or vice-versa, and indeed is a virtual machine itself (in other worlds, the JVM (Java Virtual Machine) is sort of like an operating system that manages the actual Java application). This also includes not just the VM but any native libraries that the game uses, such as OpenGL and all the rendering data it handles (which can be quite a lot - at any time there can be millions of blocks being rendered, with each vertex, 4 per face, requiring multiple bytes). Java applications can even directly allocate memory outside of the VM, usually for communication with native code, which is only limited by physical RAM. While the actual overhead varies the creator of Optifine says it is around double the memory allocated to the Java process (presumably this overhead is relatively constant, you say you were seeing 6.5 GB of usage with 4 GB allocated and 10 GB with 8 GB allocated, suggesting 2-2.5 GB, which would double the overall usage with the default of 2 GB).
Modern modpacks are also incredibly demanding due to changes made to the game over the years, in addition to ineffficiences present in modern modloaders and mods themselves (Forge uses a lot of memory and resources by itself since it was designed to allow mods to indirectly hook into the game's code, which includes a lot of memory allocation for dispatching "events", as opposed to "jar mods" which directly modified it and were thus often incompatible with other mods, but could also be far more lightweight. Many modders also do not spend much time on optimizations; I've seen code that is quite bad in terms of object creation):
I don't have any experience myself but I see 4-6+ GB being quoted for reasonably sized modpacks (example1, example2), and that's just the Java heap - in short, you need a very powerful (at least RAM-wise) system to run modern modpacks and this will probably only worsen over time (1.8 was the worst update due to giving every single block and block variant, up to thousands for some modded blocks, its own block model which requires a lot of memory).
I'm having an issue with this also but it's actually severe. I use curseforge and I have 32gb of RAM. I set the max RAM limit to 8 GB which I see as reasonable but apparently when I decided to go afk and do some other things on my PC and let Minecraft run in the background, java decided to use 19GB OF RAM. HOW DOES THIS EVEN HAPPEN. I have absolutely no clue why it does this and it caused me major problems where it wouldn't let me restart my PC unless I forced it to restart. Every other time it uses nearly 10GB. Some help would be greatly appreciated. Btw the mod pack I'm playing is project ozone 3 the full version.
When you set “java” RAM you're not setting the maximum amount of RAM the process is using. You're setting a particular type of memory size which - in normal java programs - is the larger amount: the heap memory.
Java programs have other type of ram: non-heap and native, respectively data structures that are allocated in a different way than the heap, and memory user by non-java libraries, such as various drivers including graphics (and so including textures, and so on).
So if your pack wants at least 8GiB of heap memory, you can stay sure it will go as up as 12GiB or more depending of how many entities there are in the world and how much graphics it has to allocate. That's why in modded minecraft it's vital to do entity management (non letting farm produce a lot of entities in the world in the form of object or creatures non handled/killed). Also this can block the java process but also the java i/o which saves the world on a regular basis and even if it saves, it can do a death save in which there are so many entities in the world that when you load the saved world, it gets immediately stuck.
So if your pack wants at least 8GiB of heap memory, you can stay sure it will go as up as 12GiB or more depending of how many entities there are in the world and how much graphics it has to allocate.
Entities are stored in Java heap space and the amount of render data (handled by OpenGL) associated with them is minimal compared to that needed to render chunks (just look at how many cubes an entity has vs a chunk, all entities of a given type also use a single model which is manipulated by setting the position and rotation for each piece before rendering it - compare that to chunks, where each 16x16x16 section has its own render data which is essentially static, only altered by chunk updates).
Indeed, on my old computer, I'd get "Minecraft has run out of memory" error screen if I tried using Far render distance, especially in one of my modded "mega forest" biomes, despite F3 showing plenty of free memory, as well as Task Manger (system memory), the issue being the 32 bit process space limit - reducing the then-default allocation of 1 GB to 512 MB fixed it as it gave the rest of the Java process 512 MB of additional memory to use (I still allocate 512 MB even to this day because the game doesn't need it - I've also seen no change in the memory requirements of TMCW, either Java heap space or overall process usage, despite adding hundreds of new features, including dozens of new entities/entity variants - something must be VERY wrong with "most mods and vanilla for them to use so much memory and resources).
That said, TMCW does use over twice as much process memory (around 500-600 MB) as heap space (about half out of 512 MB allocated), though this is perfectly normal and should decrease as heap usage increases (i.e. with 1 GB heap allocated I'd expect overall usage to be around 1.3 GB).
Also, this is much memory Minecraft would need if it were properly coded (I didn't even do much to optimize resource usage, this is just how well-coded versions prior to 1.8 were; "over 90% of the memory allocation is not needed at all" (yes, this is mainly referring to allocation rate but the JVM does need a bigger heap to manage it, and I wouldn't be surprised if the JVM itself needs more for housekeeping):
A default Superflat world - even 30 MB is higher than the true baseline memory usage (no memory usage by loaded chunks, which are 1 section high with 289 loaded at 8 chunks, which amounts to around 3.5 MB when including per-chunk heightmaps, biome maps, etc):
A normal world at max settings; only about a third of the maximum allocated memory is being used and about 3/4 has been allocated; there are also at least 387 entities (mob counts) loaded (mostly server-side, only 130 have been sent to the client):
A max-height Superflat world at max settings, deeper on average than 1.18; this world also has all normal features aside from surface decoration as it is too high; this includes caves and passive mobs, features exclusive to TMCW (vanilla will only spawn up to around 10 passive mobs, here there are 383, and a total of 473 mobs, loaded as they spawned during world generation, just like in a normal world; only a few pigs are actually visible, to the far left (which shows just how low a mob cap of 10 really is). 512 MB is a bit too low in this case but 768 MB would be plenty (I did allocate 768 MB when playing with my "triple height terrain" mod, which increased the ground depth to 192 layers:
Also, this is a JVM memory usage analysis; nearly all memory (93%) is being used by loaded chunks (Chunk. first entry), and of that 98% is used by block data (ChunkSection, 4th entry), which in turn uses byte arrays to store the data, as indicated by byte[] (3rd entry) - everything else is very minimal, both overall and loaded chunks only (the last entry shown is the total memory used by sheep entities; the "retained" value is not necessarily how much they use as this includes all objects they are referencing, it is accurate for "Chunk" and "ChunkSection" though). Also, versions prior to 1.3 would only need about half as much memory to load the world as they only had a single copy of the world loaded (represented by WorldServer and WorldClient):
Good morning, recently I have been having some problems with Minecraft and the use of ram, every time I try to play a minecraft modpack, in any version and any mods, it always uses the maximum allocated ram and a little more, for example, I allocate 4gb, minecraft ALWAYS uses 6.5gb, I can be on the loading screen or in the game, always the same amount. I have 16gb of memory, so the problem is when I play very heavy modpacks and I allocate 8gb ram, it always uses 10gb of ram, and sometimes I have freezes. I've tried to reinstall java, use multiple arguments and multiple clients until the original minecraft, but the error persists. In the game the usage is shown normally, however, in the task manager it is always more than allocated.
The problem is the game shows 3gb of ram use and the task manager shows 10gb and never down!
Now I'm using multimc and it shows the same, i don't know what to do.
Edit: My java version is java 8 271
I have a ryzen 2700
Rx 5700 xt
Ram 3000mhz 16gb (8x2)
This is normal, and is why you should never allocate more than half your free memory to the game (more or less, the overhead is relatively constant, about 2-2.5 GB from what you say); not only can you force your system to page to disk, which will cause lag spikes, but garbage collection will also take longer, again causing lag spikes (or more noticeable/longer spikes, ideally they are short enough to not be noticeable):
This also explains why you shouldn't allocate as much memory as you feel like; if the memory usage (in F3) only goes to say, 3 GB then 4 GB should be enough.
Also, what are your JVM arguments? Do you have -Xms or just -Xmx? -Xms will force the JVM to use all the memory available if it is equal to -Xmx, even if it isn't needed (if you do use it it shouldn't be any higher than the normal memory usage; the main benefit is during startup, as otherwise the JVM will resize the heap multiple times, slowing it down).
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?
I've seen it happen allocating 3 GB...
https://www.minecraftforum.net/forums/support/java-edition-support/2794819-minecraft-is-apparently-using-a-lot-of-memory-i
That thread may be of use to you. What you allocate to it isn't the total limit of what the entirety of Minecraft can and will use; it will be more. However, such high use wasn't normal, though it happened more than once, as well. I only had it actually get to 10 GB and complain of actually being out of memory that once though, and I then raised my page file, which is what I suspect was the issue, so make sure you're not disabling it (do NOT do this) and if you're setting a smaller static size than what Windows usually defaults to, with today's programs and RAM amounts, make sure it's still enough.
I've saw about that and i don't allocate more than 8gb ram, but the problem are in minecraft ALWAYS use max ram allocated and more, if i allocate 3gb, the game will use 4/5gb all the time, creating a world or playing in other dimension, the ram never changes and stay on more than max.
I'm don't using any argument, in the multimc i say to allocate 512 to minimun memory and 8096 to max.
My page file is managed by windows.
https://imgur.com/a/195dchd
Showing the use of ram.
Well, I can't say what's going on unless it's pre-caching or something. The old statement is "unused RAM is wasted RAM" so maybe it's using up to the limit regardless of the minimum it needs. I'm not sure.
Regardless, the question then becomes "is this a problem to you?" If you need it use less RAM, allocate less. If it's enough, then all is well and allocate less. If it's not enough, you don't have enough RAM then.
The problem is sometimes I get minecraft freezing
Is the freezing lasting multiple seconds while reflecting maximum RAM use, only to drop after the garbage collector saves it from a crash? Or is it more like stutter or micro stutter?
If it's the first one, that is strange, and I've got no answers for it. The obvious answer would be "raise your RAM allocation" but you say Minecraft chases the amount you set, whether it's increased or decreased, and then behaves this same way (freezing from being at max RAM use) regardless? Yeah, that is strange.
Does this also happen with vanilla, or only when running all of those mods? Start there to see if it's an issue with the game, or maybe a memory leak with one of the mods.
In heavy modpacks (250+ mods) it's stutter, the game freezes, the game use the max ram. (sometimes happen to lighter modpacks)
In a bit light modpack (150+ mods) it's microstutter, minecraft is using 4gb ram and downs to 2gb causing microstutter.
Doesn't happen in vanilla, only in modpacks, differents modpacks and the same problem.
Stutter during garbage collection is normal; the severity of it varies though.
You've identified RAM use is higher with mod packs with hundred of mods. That is normal too.
You need to find out if you simply need to allocated even more RAM (if you have 16 GB, I'd caution against allocating more than 8 GB), or if there is a particular bad mod or few causing runaway RAM use. Unfortunately, that is beyond my knowledge. You might just need more RAM and RAM allocation for that mod pack.
If you can't add some RAM sticks and/or allocate more RAM, then use a light modpack.
go in 5:33, see the use of ram in minecraft and in task manager, that's the problem, my minecraft is ALWAYS using more than allocated ram, even if I allocate 4gb it will use 9gb.
As I've mentioned before, the memory allocated to a Java application (using -Xmx) is only a portion of the total memory used by the entire Java process, which can be thought of like running a Windows VM on Linux or vice-versa, and indeed is a virtual machine itself (in other worlds, the JVM (Java Virtual Machine) is sort of like an operating system that manages the actual Java application). This also includes not just the VM but any native libraries that the game uses, such as OpenGL and all the rendering data it handles (which can be quite a lot - at any time there can be millions of blocks being rendered, with each vertex, 4 per face, requiring multiple bytes). Java applications can even directly allocate memory outside of the VM, usually for communication with native code, which is only limited by physical RAM. While the actual overhead varies the creator of Optifine says it is around double the memory allocated to the Java process (presumably this overhead is relatively constant, you say you were seeing 6.5 GB of usage with 4 GB allocated and 10 GB with 8 GB allocated, suggesting 2-2.5 GB, which would double the overall usage with the default of 2 GB).
Modern modpacks are also incredibly demanding due to changes made to the game over the years, in addition to ineffficiences present in modern modloaders and mods themselves (Forge uses a lot of memory and resources by itself since it was designed to allow mods to indirectly hook into the game's code, which includes a lot of memory allocation for dispatching "events", as opposed to "jar mods" which directly modified it and were thus often incompatible with other mods, but could also be far more lightweight. Many modders also do not spend much time on optimizations; I've seen code that is quite bad in terms of object creation):
https://www.reddit.com/r/feedthebeast/comments/5jhuk9/modded_mc_and_memory_usage_a_history_with_a/
I don't have any experience myself but I see 4-6+ GB being quoted for reasonably sized modpacks (example1, example2), and that's just the Java heap - in short, you need a very powerful (at least RAM-wise) system to run modern modpacks and this will probably only worsen over time (1.8 was the worst update due to giving every single block and block variant, up to thousands for some modded blocks, its own block model which requires a lot of memory).
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?
I'm having an issue with this also but it's actually severe. I use curseforge and I have 32gb of RAM. I set the max RAM limit to 8 GB which I see as reasonable but apparently when I decided to go afk and do some other things on my PC and let Minecraft run in the background, java decided to use 19GB OF RAM. HOW DOES THIS EVEN HAPPEN. I have absolutely no clue why it does this and it caused me major problems where it wouldn't let me restart my PC unless I forced it to restart. Every other time it uses nearly 10GB. Some help would be greatly appreciated. Btw the mod pack I'm playing is project ozone 3 the full version.
When you set “java” RAM you're not setting the maximum amount of RAM the process is using. You're setting a particular type of memory size which - in normal java programs - is the larger amount: the heap memory.
Java programs have other type of ram: non-heap and native, respectively data structures that are allocated in a different way than the heap, and memory user by non-java libraries, such as various drivers including graphics (and so including textures, and so on).
So if your pack wants at least 8GiB of heap memory, you can stay sure it will go as up as 12GiB or more depending of how many entities there are in the world and how much graphics it has to allocate. That's why in modded minecraft it's vital to do entity management (non letting farm produce a lot of entities in the world in the form of object or creatures non handled/killed). Also this can block the java process but also the java i/o which saves the world on a regular basis and even if it saves, it can do a death save in which there are so many entities in the world that when you load the saved world, it gets immediately stuck.
Entities are stored in Java heap space and the amount of render data (handled by OpenGL) associated with them is minimal compared to that needed to render chunks (just look at how many cubes an entity has vs a chunk, all entities of a given type also use a single model which is manipulated by setting the position and rotation for each piece before rendering it - compare that to chunks, where each 16x16x16 section has its own render data which is essentially static, only altered by chunk updates).
Indeed, on my old computer, I'd get "Minecraft has run out of memory" error screen if I tried using Far render distance, especially in one of my modded "mega forest" biomes, despite F3 showing plenty of free memory, as well as Task Manger (system memory), the issue being the 32 bit process space limit - reducing the then-default allocation of 1 GB to 512 MB fixed it as it gave the rest of the Java process 512 MB of additional memory to use (I still allocate 512 MB even to this day because the game doesn't need it - I've also seen no change in the memory requirements of TMCW, either Java heap space or overall process usage, despite adding hundreds of new features, including dozens of new entities/entity variants - something must be VERY wrong with "most mods and vanilla for them to use so much memory and resources).
That said, TMCW does use over twice as much process memory (around 500-600 MB) as heap space (about half out of 512 MB allocated), though this is perfectly normal and should decrease as heap usage increases (i.e. with 1 GB heap allocated I'd expect overall usage to be around 1.3 GB).
Also, this is much memory Minecraft would need if it were properly coded (I didn't even do much to optimize resource usage, this is just how well-coded versions prior to 1.8 were; "over 90% of the memory allocation is not needed at all" (yes, this is mainly referring to allocation rate but the JVM does need a bigger heap to manage it, and I wouldn't be surprised if the JVM itself needs more for housekeeping):
A normal world at max settings; only about a third of the maximum allocated memory is being used and about 3/4 has been allocated; there are also at least 387 entities (mob counts) loaded (mostly server-side, only 130 have been sent to the client):
A max-height Superflat world at max settings, deeper on average than 1.18; this world also has all normal features aside from surface decoration as it is too high; this includes caves and passive mobs, features exclusive to TMCW (vanilla will only spawn up to around 10 passive mobs, here there are 383, and a total of 473 mobs, loaded as they spawned during world generation, just like in a normal world; only a few pigs are actually visible, to the far left (which shows just how low a mob cap of 10 really is). 512 MB is a bit too low in this case but 768 MB would be plenty (I did allocate 768 MB when playing with my "triple height terrain" mod, which increased the ground depth to 192 layers:
Also, this is a JVM memory usage analysis; nearly all memory (93%) is being used by loaded chunks (Chunk. first entry), and of that 98% is used by block data (ChunkSection, 4th entry), which in turn uses byte arrays to store the data, as indicated by byte[] (3rd entry) - everything else is very minimal, both overall and loaded chunks only (the last entry shown is the total memory used by sheep entities; the "retained" value is not necessarily how much they use as this includes all objects they are referencing, it is accurate for "Chunk" and "ChunkSection" though). Also, versions prior to 1.3 would only need about half as much memory to load the world as they only had a single copy of the world loaded (represented by WorldServer and WorldClient):
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?