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

TagKey creation leads to memory leak

    XMLWordPrintable

Details

    • Plausible
    • Crash
    • Normal

    Description

      The TagKey class has a memory leak when creating new TagKey s using the create method. When create is called, a new TagKey is added to VALUES, which will always hold onto the new reference. This is an issue because loading worlds with lots of custom recipes, tags, loot tables, etc. with custom tags will begin to fill this Interner up, never being dereferenced. Some commands can take a tag as a parameter, allowing many TagKey s to be created and begin to fill up memory.

      Replacing VALUES with Interners.newWeakInterner() should remove this memory leak.

      Test:

      This is the result of the Minecraft server GUI when adding around 65536 new tags via commands. Each tag had the format execute if block 0 0 0 #minecraft:fake_tag0 as @s run say hi, with 0 being replaced by a unique number so that no two tags with the same name existed. The memory graph clearly shows a increase when the commands were being run, with level sections before and after. While the consumed memory was not much, this slight memory leak does exist.

      Attachments

        Activity

          People

            gegy1000 [Mojang] Gegy
            OroArmor Eli Orona
            Votes:
            8 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              CHK: