mojira.dev
MC-241294

Memory exhaustion when handling snowy terrain from pre-1.18 worlds.

I've been noticing some performance issues when moving around in a world last run in 1.17, which seems to kick in with old, snow-covered terrain. The game consumes more and more memory until the game regularly bumps into the 2 GiB limit, causing intermittent (but frequent) freezes. Here's what I've been able to figure:

  • The issue does not kick in with old terrain not covered in snow (that is, wandering around grassy areas seems to have no effect).

  • Last week's snapshot didn't seem to have this issue when I tested the same old level, and went to my base in the snow (though I may not have played long enough for the memory to be eaten).

  • Saving & quitting when RAM usage is high, then restarting Minecraft and loading the level back in, does not immediately chew into the RAM again, hinting at the problem being some kind of memory leak (as opposed to some operation being naturally memory-intensive).

  • There is no issue wandering around snowy areas in a brand-new, fully 1.18 world, not even in amplified worlds. This only came up when walking around in a pre-1.18 world. For fully new worlds, the memory stays between 800 and 1500 MiB, regardless of how long I play.

It seems to me that something about how old chunks are upgraded is causing the issue, with new caves underneath being the likely culprit (biome blending might be a contributing factor; I have no way of knowing for certain when I'm surrounded by 1.17 chunks vs. when I'm asking the game to build new ones and blend them into old ones).

The compressed JFR recording 1.18_pre1_default_1.17_world.jfr.xz represents a fresh copy of my 1.17 world, where I last left off in a grassy plains area. With the help of a zoom level 4/4 map, I made my way to my base in the snowy plains. The following interesting timestamps are to help in looking at the data in the recording (I don't know if JFR preserves timezone info, so I'm presenting them as a simple number of seconds since the epoch):

  • At 1636720284 is when I set foot in the snowy plains. A bit before this time I took a detour through a hole in my map that hinted at having some slightly snowy windswept hills. That detour resulted in the memory usage floor going up from around 800 to 900 MiB, but with the ceiling still at 1500 MiB. After this time, both the floor and ceiling started to rise the more time I spent in the snow.

  • At 1636720596 the stuttering got to the point where I knew it would never escape the cycle of freezes, and from that point on to the end of the recording I did not move at all in the game world. This is to show that the problem, at a point, isn't simply that I keep asking the game to process more old chunks.

The reason why I'm at all confident the snow is (somehow) the issue is that I spent another test walking along (as best as I could tell) the border between 1.17 and 1.18 in a large stretch of non-snowy terrain, and went longer than the JFR recording above without noticeable gameplay issues. The snow itself may not be the issue, but it seems to be a good predictor of when the game starts eating up memory.

I was unable to compress my JFR recording of a fully-1.18 Default world enough to upload, so I've provided comparison screenshots of the Used Heap graph in JMC between a fully 1.18 world and the JFR I could upload.

Attachments

Comments 6

Does MC-239682 describe your issue?

I don't think so, since that bug is about using some kind of structure in a new world, while this bug only crops up in old worlds and doesn't require adding any additional content to the world beyond what the vanilla game comes with. Additionally, that bug describes something that takes 24 hours (real time or in-game?) to trigger, while this under the right conditions takes just 10 real world minutes. They could possibly be the same issue underneath, but I feel like only a dev would be able to find that out.

Problem still exists in 1.18 prerelease 2, though it did seem to take longer to get the game to enter that freezing loop. I also noticed that pressing F3+A (just to see if reloading chunks would clear out memory) didn't help the issue, but it did drop the amount of used RAM needed to lock up the screen, curiously. When testing this time, the game would lock up for a second whenever the F3 screen reported about 1900 MiB used, but after hitting F3+A it would instead lock up when it said about 1800 MiB. Not sure if that means anything, but I figured I'd mention it just in case.

Is this still an issue in 1.18 pre4 or later?

The memory usage still climbs over time when exploring the terrain, but I couldn't get the game to enter a freezing loop in pre4. Pauses occurred a couple times, but they were all one-time things. Loading the level back up and walking over terrain I had walked over before showed no issues, as I'd noticed before, so it definitely seems like a one-time issue around updating chunks.

Point is, it's definitely a lot better than it was before. I'm not worried about how to work around the issue when 1.18 comes out in full anymore, but there's still something being left behind in memory. I can capture a new JFR for pre4 later if that would be useful.

Since this was marked as "can't reproduce", I'll share some details in case this issue is more specific to my world than I initially assumed. The world seed is 235379857779490613, and the snowy terrain in question can be found at 1329 / / -127. I had mapped out all but a few map pixels' worth of this snowy area in 1.16 (though I'd guess there's not much difference between that and how it would've generated in 1.17, and I can't say for certain there aren't some 1.17 chunks here and there). I had last left my save at 609 / / -642, and so all my tests of this world in the prereleases start from there. (There is, of course, already-explored terrain connecting that start point to the tundra.)

I've also got another JFR recording showing a trip in pre4. Relevant timestamps are 1637313244 for when I started walking on snow and 1637313675 for when I stood still (until the end of the recording). Again, the standing still is to help show that the memory usage remains high, and it's not just the result of constantly asking the game to work on yet more chunks.

Faye N

(Unassigned)

Unconfirmed

(Unassigned)

1.18 Pre-release 1, 1.18 Pre-release 2

Retrieved