I THINK I fixed it. I looked more into the MapItemRenderer and tried creating my own texture handler based off of it.
After running the game for a solid 10 minutes while running the redraw process (an amount of time which would have definitely ate up a bunch of memory by now), the leak seems to have been fixed.
This is what I came up with to fix it:
package com.Whodundid.main.util;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
public class InGameTextureHandler {
private final TextureManager textureManager;
private final DynamicTexture texture;
private int[] textureData;
public InGameTextureHandler(TextureManager manager, DynamicTexture textureIn) {
this.textureManager = manager;
this.texture = textureIn;
this.textureData = textureIn.getTextureData();
}
public void updateTextureData(BufferedImage newImage) {
int[] newImgData = ((DataBufferInt)newImage.getRaster().getDataBuffer()).getData();
if (this.textureData.length == newImgData.length) {
for (int i = 0; i < newImgData.length; i++) {
this.textureData[i] = newImgData[i];
}
}
this.texture.updateDynamicTexture();
}
public ResourceLocation getTextureLocation() {
return textureManager.getDynamicTextureLocation("texture/", texture);
}
}
Then back in the class where I am re-creating the BufferedImage I do:
public static BufferedImage image = new BufferedImage(75, 75, BufferedImage.TYPE_INT_ARGB);
public static DynamicTexture redrawnImage = new DynamicTexture(image);
public static InGameTextureHandler handler = new InGameTextureHandler(Minecraft.getMinecraft.getTextureManager(), redrawnImage);
public static void updateImage() {
//(re-create the BufferedImage 'image' here)
handler.updateTextureData(image);
}