[MC-1628] Minecraft runs out of memory when you switch a lot between worlds Created: 01/Nov/12  Updated: 06/Sep/15  Resolved: 23/Jul/13

Status: Resolved
Project: Minecraft: Java Edition
Component/s: None
Affects Version/s: Minecraft 1.4.2, Minecraft 1.4.4, Minecraft 1.4.5, Minecraft 1.4.6, Minecraft 1.5
Fix Version/s: Minecraft 1.6.2

Type: Bug
Reporter: Jeffrey Kog Assignee: Unassigned
Resolution: Fixed Votes: 4
Labels: OSX, memory
Environment:

Mac OS 10.8.2
Java 1.6


Attachments: PNG File 2013-08-04_19.28.32.png     PNG File 2013-08-04_19.47.13.png     PNG File 2013-08-04_20.01.23.png     PNG File 2013-08-04_20.15.27.png     PNG File 2013-08-04_20.43.47.png     Text File crash-2013-08-04_16.48.54-client.txt    
Issue Links:
Duplicate
is duplicated by MC-17955 Switching between saves memory leak? Resolved
is duplicated by MC-29277 SSP Leaking memory when connecting an... Resolved
is duplicated by MC-2993 Memory leak when changing dimensions ... Resolved
Confirmation Status: Unconfirmed

 Description   

After switching between worlds like 25 times, minecraft runs out of memory

I created 2 new superflat worlds with the "Redstone Ready" template.
Each time i switch to another one of these, the game consumes 60 - 100 mb more ram!

What I expected to happen was...:
I expected to be able to switch between singleplayer worlds as much as i want

What actually happened was...:
Minecraft starts using more and more ram, making it crash because it's out of memory

Steps to Reproduce:
1. Leave current world
2. Join another world
3. Leave this world
4. Join another world
And so on like 25-35 times until minecraft crashes



 Comments   
Comment by Kumasasa [ 04/Aug/13 ]

@Dídac Garcia:

  • Please attach the complete output of the "Development console" of the launcher. CTRL-A, CTRL-C there, CTRL-V in the ticket.
  • Please attach the crash report ( minecraft/crash-reports/crash-XXXX.txt ).
Comment by Dídac García [ 04/Aug/13 ]

I have the same problem. I changed 10 or 12 times between different worlds and Minecraft crashed.

Mac OS X 10.7.5. Java 1.6. Minecraft 1.6.2.

Comment by Callum Watson [ 04/Aug/13 ]

Contrary to Kumasasa's request, I installed the latest development version of java, java 8, and found all the performance problems vanish. The cpu is still fairly high but the RAM stays low, and my fps stuck to vsync even whilst loading worlds.

Comment by Markku [ 04/Aug/13 ]

Callum, were those memory usage numbers observed in an operating system tool, or in the client itself? If former, it is normal (I can easily reach 1.7G usage with java's max parameter set for 1G). If latter, there would be a bug in the JVM itself (not obeying the max parameter). (The maximum parameter specifies the java's maximum internal 'heap' size, not the maximum RAM the JVM can request from the operating system.)

Coming to think of it, as you have such a humble CPU (by modern standards), what is your system's total RAM amount?

Also note that there is currently a bug that puts weaker CPU's to knees (and dual-core 1.3GHz would be counted as weak in this context), related to zombie's pathing (MC-17630)... Combine that with the increased need for garbage collection once the heap starts getting full (like during your 4th world), and bad performance can be expected. A good test to try would be run the game on peaceful difficult (no zombies to wreck the CPU...)

Comment by Kumasasa [ 04/Aug/13 ]

Cannot confirm.
Did the same (created 5 worlds, exited each after 5-15 minutes)
Created 5 Worlds, see screenshots.
javaw.exe RAM usage at the end: 1076 M

Comment by Kumasasa [ 04/Aug/13 ]

Callum Watson, Please don't use early access versions of Java.

Comment by Callum Watson [ 04/Aug/13 ]

Uploaded a forced crash

Comment by Callum Watson [ 04/Aug/13 ]

RAM upon 1.6.2 startup: 240640k
After creating a world and leaving after 5 mins: 511228k - Slight Lag
Creation of a second world and leaving after 5 mins: 755,224k - Major Lag
Creation of a third world and leaving after 5 mins: 1063,384k - Unplayable Lag
Creation of a fourth world and leaving after 5 mins: 1370028k - The memory limit is default, 1024MB

CPU usage upon startup: 20-50% (1.3Ghz dual core, javaw.exe usage)
In-game: 70-95%

Old Usage using the 1.5.2 and lower launcher w/ 1.5.2: 10% on menu, 40% in-game

Evidently the memory leak isn't fixed in 1.6.2

Comment by Kumasasa [ 24/Jul/13 ]

Ok. Fine.

Comment by A Y [ 24/Jul/13 ]

I tested today with 1.6.2 and there is everything allright with the RAM now

Comment by Kumasasa [ 23/Jul/13 ]

No answer, assuming fixed in 1.6.2.

Comment by Kumasasa [ 15/Jul/13 ]

Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

If so, please force a crash by pressing F3 + C for 10 seconds while ingame short before the memory is exausted and attach the crash report here.

Comment by Austin [ 13/Jul/13 ]

try doing it slower so you can switch more times

Comment by Jeffrey Kog [ 17/Mar/13 ]

It did crash with that nice out of memory screen. I threw away the report, will try to reproduce it today and i will post the report here.

Also, i am not using any texturepack. Just vanilla.

Comment by Kumasasa [ 17/Mar/13 ]

As long as the memory doesn't go over some limits, the GC won't kick in.

But: Did 1.5 run out of memory (with a crash) or did you just observe an increase in memory usage ? If the latter, that ticket can be resolved.

Another question: Do you use texture packs ? If yes, this issue may be related to MC-11439

Comment by Jeffrey Kog [ 17/Mar/13 ]

But if all these additional resources are unneccesary, then the garbagecollector should get rid of them. Right?

Comment by Jeffrey Kog [ 17/Mar/13 ]

I tested this again yesterday. The ram gain between world switches is smaller than it was before, but this is still an issue in the current version (1.5)

Comment by Markku [ 15/Mar/13 ]

On 1.5 it still seems to be like I described for 1.4.7; starts around 700-800MB (total 'commit' reported by win7 tools), but quickly ramps upto around 1.7GB (with 1GB heap). After that, it seems go up and down a bit, but apparently very slowly up, average maybe 5-10MB per world load at most. At least I can not get it to leak so badly as described in the description, and I run out of new worlds to load. Thus, not an issue for me.

(Java's heap seemed to working just fine, not even getting past 600MB at any time.)

(I didn't check switching specifically between two superflats, though, but various flat worlds seemed to be easier on memory anyway.)

This could be Mac (or perhaps even Mac LWJGL, or hardware drivers) specific issue, not reproducible on windows 7.

Comment by Tails [ 15/Mar/13 ]

Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Comment by Kumasasa [ 19/Jan/13 ]

Started minecraft with

java -Xmx1g -Xms512M -cp Minecraft.exe net.minecraft.LauncherFrame 

leaving it running overnight, switched a lot of worlds (15 times, some single player, some multiplayer), memory for java.exe is now (according to taskmanager) oscillating around 1 GB .
Debug screen says

Used memory: 35% (325MB) of 910MB
Allocated memory: 70% (643MB)
Comment by A Y [ 18/Jan/13 ]

@[Mod] Kumasasa i read the numbers from the task manager (processes => javaw.exe) ... Normaly i also do not have problems with running out Memory, but these days i worked on a adventure map and had to copy my original world often to test new features but after 7-8 new world tests minecraft run out of Memory

Comment by Markku [ 18/Jan/13 ]

I was able to get win7 throw its own out of memory warnings simply due to minecraft 1.4.7 idling long enough on the background (And I have 6G of RAM, normally idling at around 1.9GB used) Though that sounds more like a memory leak in the JVM itself (or some native code somewhere), not in Java code, as, like mentioned, Java itself does have its own allocation limit (and I have it at that safe 1GB, too).

(Edit But with repeated world switching I could not get as fast leaking (at least not with 1.4.7); memory usage did slowly creep up, though, from about 700MB (JVM + java heap) to around 1.6GB after about 15 switches or reloads of the same world. First large growth, but in the end typically only 20-30MB per switch. Definitely not good anyway.

Comment by Kumasasa [ 18/Jan/13 ]

@Alper Yetis: From where do you read the numbers and which parameters do you use for the JVM ?
Keep in mind that JVM always allocates RAM until exhausted, then the garbage collection kicks in.
I use always the default ( -Xms512m -Xmx1024m) and never run in memory issues, even when heavily switching worlds (single and multiplayer)

Comment by A Y [ 18/Jan/13 ]

Wow..... here a list of my increasing ram:
280 Mb start Minecraft
630 Mb World 1
800 Mb World 2
910 Mb World 3
1030 Mb World 4
1190 Mb World 5
1280 Mb World 6
1310 Mb World 7 => here my computer starts to lag and i got 4 Gb RAM

Comment by Stefan van der Velden [ 27/Dec/12 ]

Another thing to note is that the mod Mystcraft is also affected by this, this means i cannot switch between ages much, which is really annoying as my resources are in the overworld but i am doing work in an age. Please fix this memory leak Mojang!

Comment by DarkWolff [ 27/Dec/12 ]

I've noticed this recently in my 1.4.6 SMP world, however the problem happens to me when switching between the Overworld and the Nether.

Even standing still my javaw.exe's memory steadily climbs, though eventually it will stop until walking around a bit. Going into and out of the nether in one trip usually increases my memory consumption enough the game gets really choppy.

Comment by Jeffrey Kog [ 03/Nov/12 ]

Some new information about this bug.

I created 2 new superflat worlds with the "Redstone Ready" template.
Each time i switch to another one of these, the game consumes 60 - 100 mb more ram!
This is more than i expected to be.

Comment by Talven81 [ 01/Nov/12 ]

Even with limited block types, there can be memory leaks in other areas. All games suffer from memory leaks, the question is how severe is the leak. Minor leaks can usually be ignored while major leaks need to be fixed as it can become overbearing on the system. That was one of the reasons for pulling back on 1.4.1 and instead releasing 1.4.2.

To make this bug report more complete, I would recommend the following:

  • Upload the map(s) you are working on.
  • Report how much ADDITIONAL RAM is consumed between each switch. 2 switches won't give you an accurate number, but if you do it a few times you should be able to see an average amount of consumed RAM that isn't released as the working set size increases.
Comment by Jeffrey Kog [ 01/Nov/12 ]

Yeah for me it's not too big of a problem that i have to restart minecraft after some switching, but it should not be necessary. Also it are just normal flat sandstone worlds with nothing special in them

Comment by Allan K [ 01/Nov/12 ]

It's crazy, I know, but Minecraft does suffer from memory leaks.

The best course of action you can take at present would be restarting the game after the 20th time you've switched maps. Or, assuming that you are trying to transfer something from Creative to Survival, take photos of whatever you've built so you don't have to swap the maps so much.

I frankly think this will be a tough one to solve, as this (plus the other memory leaks) have not been resolved for a while now.

Comment by Talven81 [ 01/Nov/12 ]

Sounds like a memory leak. This could happen due to loading worlds and all assets not being unloaded when leaving.

Generated at Sun Jan 12 11:55:05 UTC 2025 using Jira 9.12.2#9120002-sha1:301bf498dd45d800842af0b84230f1bb58606c13.