Forum Stats

  • 3,874,111 Users
  • 2,266,682 Discussions


java.lang.OutOfMemoryError: Java heap space

I get the below exception when ever I upload an image of size 3500X3000.

java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.<init>(Unknown Source)
at java.awt.image.Raster.createPackedRaster(Unknown Source)
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
at java.awt.image.BufferedImage.<init>(Unknown Source)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(Unknown Source)
at sun.java2d.loops.MaskBlit$General.MaskBlit(Unknown Source)
at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Unknown Source)
at sun.java2d.pipe.DrawImage.blitSurfaceData(Unknown Source)
at sun.java2d.pipe.DrawImage.renderImageCopy(Unknown Source)
at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)
at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)
at sun.java2d.pipe.ValidatePipe.copyImage(Unknown Source)
at sun.java2d.SunGraphics2D.copyImage(Unknown Source)
at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
at ilog.views.IlvGraphicUtil.DrawImage(Unknown Source)
at ilog.views.graphic.IlvIcon.draw(Unknown Source)
at ilog.views.IlvGraphic.callDraw(Unknown Source)
at ilog.views.IlvManagerLayer$4.apply(Unknown Source)
at ilog.views.IlvIndexedSet.a(Unknown Source)
at ilog.views.IlvIndexedSet.mapIntersects(Unknown Source)
at ilog.views.IlvManagerLayer.drawImpl(Unknown Source)
at ilog.views.IlvManagerLayer.draw(Unknown Source)
at ilog.views.IlvManager.draw(Unknown Source)
at ilog.cpl.graph.IlpGraphView$1.draw(Unknown Source)
at ilog.views.IlvManagerView.a(Unknown Source)
at ilog.views.IlvManagerView.b(Unknown Source)
at ilog.views.IlvManagerView.a(Unknown Source)
at ilog.views.IlvManagerView.paint(Unknown Source)
at ilog.cpl.graphic.views.IlpManagerView.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)

Below is the code snippet, which I am using it to read the image file.

private BufferedImage getBufferedImageFromURL(
final NbURLAccessService urls, URL imageURL)
InputStream stream = null;
BufferedImage bufferedImage = null;

stream = urls.getContents(imageURL);
bufferedImage =; // this where I get the exception
catch (IOException e)
Logger.getLogger(PACKAGE_NAME).logp(Level.WARNING , PACKAGE_NAME, "getBufferedImageFromURL", "OEEVWT001: Exception "+e);//$NON-NLS-1$ //$NON-NLS-2$

ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, e);

return bufferedImage;

Please help me resolve this issue.
Apart from increasing heap size, is there any other solution to solve this issue?

Edited by: user8902132 on Dec 20, 2010 4:08 AM


  • tschodt
    tschodt Member Posts: 537
    edited Dec 25, 2010 6:15AM
    user8902132 wrote:
    Apart from increasing heap size, is there any other solution to solve this issue?
    Either increase heap size
    java [url]-Xmx1g
    or upload smaller files.
  • anandvitcse
    anandvitcse Member Posts: 6 Blue Ribbon
    increase java heap memory.

    for examples please refer
  • 845308
    845308 Member Posts: 1

    Open your *.hprof with the help of MAT tool.

    This will give you the complete snap shot of your heap memory.The tool will help you in idnetifying the suspects and solutions.

    Based upon your analysis you can decide if you want to increase the heap memory or do you have any other alternative solution.

    Can you please also publish the current Heap settiings and GC settings of your server.If possible please attach the *.hprof file as well.

    If the image upload tool is taking time.Please take 3/4 heap dumps in regular interval of time using Jmap command.And anaylse the trend of heap memory.

This discussion has been closed.