mojira.dev
MC-234995

OutOfMemory crash upon attempting to save a world with very large amounts of block entities

The bug

Very large amounts of block entities (in this case, furnaces) cause intense server-side lag (MC-117075) and use up excessive memory. This will cause the world or certain chunks to fail to save or corrupt, and the game to run out of memory and crash. This does not happen on superflat worlds with furnaces.

To reproduce

1. Create a new world and switch to spectator mode.

2. Execute /fill ~50 ~ ~50 ~-50 ~2 ~-50 furnace and create multiple layers of tens of thousands of furnaces in the world.
3. Continue to execute the commands up to y=255 until about a million furnaces are placed.
4. Notice how extreme lag occurs, and observe the Mem usage steadily going up.
5. Quit the world.
6. ❌ The world will get stuck in the saving world screen, until failing to save and crashing due to java.lang.OutOfMemoryError: Java heap space.

Linked issues

Attachments

Comments 12

Testing with just enough block entities to not crash the game, it is single-handedly using over 2.8 GB of RAM, even while in the main menu screen. Normally it is about 2~2.4 GB.

This is essentially the same error that causes chunk-bans on 2B2T. (Note: chunk-bans are different than MC-117075 because they occur while loading chunks.) Furnaces are technically storage blocks and thus require more memory than regular blocks. Minecraft cannot handle writing all of this memory to the disk and times out, giving a memory overload error. It is impossible to work around or prevent this error, since block entities inherently require more RAM than any other block.

@unknown That chunk-ban bug is probably in this Forge pull request link, which states that chunks with large amounts of block entities (about 32,000) in a chunk causes a packet called SChunkDataPacket to overflow. This is probably a different issue, unless I manage to crash the game using furnaces in a single chunk.

Weirdly enough, this does not seem to happen on superflat worlds.

2 more comments

I've started 2 1.18-pre1 worlds, and both started crashing at auto-save after about an hour of normal casual play. No mods, no large crafting builds, just exploring with a single crafting table and one furnace.

Intel Core i7-6700 4.0GHz
16GB Ram
Win 10 Home 64-bit
OS build 19043.1348

Crash report:

[media]

@unknown That's a completely different issue, probably MC-239682 / MC-240589.

I wouldn't be surprised if it happened after pausing the game like MC-240589. Should have searched for "Out of memory", not just "OutOfMemory". 🙂

In 1.19, I got a more specific out of memory error:

[16:00:11] [IO-Worker-33/ERROR]: Caught exception in thread Thread[IO-Worker-33,10,main]
java.lang.OutOfMemoryError: Java heap space: failed reallocation of scalar replaced objects

ampolive

(Unassigned)

Confirmed

Platform

Important

Crash, Performance

OutOfMemory, block-entity, crash, memory-allocation

1.17.1, 21w37a, 21w38a, 21w39a, 21w40a, ..., 1.19, 1.19.1 Pre-release 4, 1.19.2, 23w04a, 1.20.4

Retrieved