How to improve and not get OutOfMemory?
Hello!I use to get outof memory on 2 methods looking like:
public void snapImageFile(String filename)
{
BufferedImage bImage = doRender(dim.width, dim.height);
try
{
FileOutputStream fos = new FileOutputStream(filename+"." + imageType);
BufferedOutputStream bos = new BufferedOutputStream(fos);
ImageIO.write(bImage,imageType,bos);
bos.flush();
fos.close();
}
catch (Exception e)
{
System.out.println(e);
}
}
public void writeImage(OutputStream outputStream)
{
BufferedImage bImage = doRender(dim.width, dim.height);
try
{
BufferedOutputStream bos = new BufferedOutputStream(outputStream);
ImageIO.write(bImage,imageType,bos);
bos.flush();
}
catch (Exception e)
{
System.out.println(e);
}
}
Do you guys got any ideeas how to improve them?
Best reagrsd
Fredrik
