I am using the following program for printing png images (large images 300 dpi to 600 dpi). But its taking a lot of memory after printing some images and program is exiting with "You have less virtual memory " , "Unable to allocate memory"....

here is my print method
Code:
public int print (Graphics g, PageFormat pageFormat, int page){
try{

if(page >= totalPages)
return NO_SUCH_PAGE;

if(currentPage < 0 || currentPage != page){
image=null;
scale = -1;
System.gc();
setImage(page);}

Graphics2D g2d = (Graphics2D) g;
if(image != null){
double imageableWidth=pageFormat.getImageableWidth();
double imageableHeight=pageFormat.getImageableHeight();
double imageableX=pageFormat.getImageableX();
double imageableY=pageFormat.getImageableY();

if(scale < 0)
scale = Math.min(imageableWidth/width,imageableHeight/height);
g2d.translate(imageableX,imageableY);

if(scale<=1) { g2d.scale(scale,scale);}

if(height > 600) { divFactor = height / 600 ;}

newHeight = height/divFactor;

while(count<=divFactor){
BufferedImage im = image.getSubimage(0,y,width,newHeight);
g2d.drawImage(im,0,y,null);
im.flush();
im = null;
count++;
y += newHeight;
}
count = 1;
y = 0;
newHeight = 0;
divFactor = 1;
image.flush();
scale = -1;
}
else
System.out.println("Printing Error for page "+page);

g2d.dispose();
g2d = null;
g.dispose();
g = null;
currentPage = page;

}catch(OutOfMemoryError err)
{
System.out.println("OutOfMemoryError in Print: " + err);
return NO_SUCH_PAGE;
}
catch(Exception e){
System.out.println("(print ) ERROR: " + e);
return NO_SUCH_PAGE;
}
return Printable.PAGE_EXISTS;
}

and setImage method :
public void setImage(int pathcount) throws OutOfMemoryError {
try{
URL url = new URL(paths[pathcount]);
InputStream in = url.openStream();

//ImageInputStream imin = ImageIO.createImageInputStream(new BufferedInputStream(in));
ImageInputStream imin = ImageIO.createImageInputStream(in);

Iterator readers = ImageIO.getImageReaders(imin);

if (!readers.hasNext())
throw new IOException("No readers");

ImageReader reader = (ImageReader) readers.next();
reader.setInput(imin);
width = reader.getWidth(0);
height = reader.getHeight(0);
image = reader.read(0);
reader.abort();
reader.dispose();
reader = null;
readers = null;
image.flush();
imin = null;
in = null;
url = null;
}catch(OutOfMemoryError err)
{ System.out.println("OutOfMemoryError in Reading: " + err);
image = null;
}
catch(Exception e){
System.out.println("Error: " + e);
e.printStackTrace();
image = null;
}
}

paths is a global string array which contains png image urls and initial value of currentPage is -1 which used to call setImage only once per image
After printing some images memory usage increasing (using task manager->performance->PF Usage) a lot. I have 256MB RAM at first PF usage is begining at 150MB and increasing upto 610MB, at this point application is exiting. What i think is java objects are not garbage collecting and memory usage is increaing. Whats wrong i am doing here , How can i reduce the memory usage?