code: public void dispose() {
  		for (int layer = 0; layer < 4; layer++) {
  			Graphics2D graphics = layeredGraphics[layer];
  			if (graphics != null) {
  				graphics.dispose();
  				layeredGraphics[layer] = null;
  			}
  			BufferedImage image = layeredImage[layer];
  			if (image != null) {
  				image.flush();
  				layeredImage[layer] = null;
  			}
  		}
  	}
docs: Dispose of the layered graphics and images