Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.OutOfMemoryError: Java heap space

user8902132Dec 20 2010 — edited Mar 7 2011
Hi,
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;

try
{
stream = urls.getContents(imageURL);
bufferedImage = ImageIO.read(stream); // 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

Comments

rickepm

index position 0 of the array is not used..

Cindy_Paul

thanks Rick, but how to fix that.

Cindy

rickepm
Answer

class Testarray

{

String name;

public static void main (String [] args)

{

Testarray[] h= new Testarray[3];

int z= -1;

while (z<2)

{

z=z+1;

h[z] = new Testarray();

h[z].name="abc";

if (z==1) {

h[z].name="def";

}

if (z==2){

h[z].name="xyz";

}

System.out.println(h[z].name + " is a");

System.out.println("good Testarray name");

}

}

}

Marked as Answer by Cindy_Paul · Sep 27 2020
Cindy_Paul

worked .. thanks...

unknown-7404

I am practicing this program and its giving me error:

Then I suggest you download and use a GUI development system that has a debugger so you can learn how to step thru the code one line at a time and find errors.

https://netbeans.org/downloads/

Until you learn how to debug your own code you will continue to have problems.

TPD-Opitz

Cindy_Paul wrote:

worked .. thanks...

Did you learn why ?

bye

TPD

1 - 6
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 4 2011
Added on Dec 20 2010
3 comments
2,258 views