com.mojang.blaze3d.platform.TextureUtil#readResource(inputStream) leads to memory leakage problem.
This method throws IOException. However, if it throws, this method won't return the native pointer so you can't free the memory via MemoryUtil.memFree(). For example, #readResourceAsString finally block, the ByteBuffer is null if an IOException is catched. This will take up more and more memory along with the game.
To solve this, add a catch block inside #readResource, free the memory first, and then throw the catched exception.
...
ByteBuffer byteBuffer2 = null;
try {
// reading
...
} catch (Throwable t) {
MemoryUtil.memFree(byteBuffer2);
throw t;
}
return byteBuffer2;
Relevant Forge issue link.