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.
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.