Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-203131

Setting the weight in Template Pool to high values will lag world and can cause out of memory error.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 1.17 Pre-release 1
    • 1.16.3, 1.16.4 Release Candidate 1, 1.16.4
    • None
    • Confirmed
    • Crash, Custom Worlds
    • Very Important

      So for jigsaw structures such as villages or outposts, they have what are called template pools and in these pools are pieces of the structure with a weight of how often they get picked. What has been reported is that if someone's datapack sets a piece's weight to a very high value by datapack or a mod, the game will lag hard when loading up the world and when going to the structure. If the weight is high enough, the JVM will run out of memory!

       

      The reason for this is that StructureTemplatePool (mojmap) constructor makes a list. Then makes a new instance of the element x number of times where x is the weight's number. And then add those elements to the list so that they can do a rand.nextInt to grab a random element. Now, going back a bit, making a new instance x number of times means the game's memory gets eaten up very fast and lag will occur from that loop. If too high, the game cannot start at all until the datapack is removed.

       

      Attached is a datapack to reproduce the issue and a pretty picture of the JVM running out of memory despite being given 8GB.

            slicedlime [Mojang] slicedlime
            TelepathicGrunt TelepathicGrunt
            Votes:
            13 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: