i’ve written a threaded class which draws a background image and some rectangles on a temp buffered image,
and then draws the temp buffered image to a volatile image. performance seems to be fine, buffering working good.
but when i try to set a new background image, the old one is never disposed so my memory usage increases.
//code to overwrite the old bgImage with a new image (newMap) with different size
bgImage = gc.createCompatibleImage(newMap.getWidth(), newMap.getHeight());
Graphics2D g2d = (Graphics2D)bgImage.getGraphics();
g2d.drawImage(newMap, 0, 0, null);
g2d.dispose();
i tried to stop the thread, then replace the bgImage, and start the thread again (thought the image might be in use or something) but no use…