Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Out of memmory for no reason?

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
GB
g.drawImage(imageInfo, 0, 0, (int)(this.getSize()).getWidth(), (int)(this.getSize()).getHeight(), this);

This method scales my image imageInfo. Why do I get

Exception occurred during event dispatching:
java.lang.OutOfMemoryError
<<no stack trace available>>
When this code is run. My image is 2000 by 2000 abouts maybe larger.

When I use the normal drawImage method it works but I would like it scale can anyone help?

Chris
 
I put try catch aroud the statement g.drawImage(imageInfo, 0, 0, (int)(this.getSize()).getWidth(), (int)(this.getSize()).getHeight(), this);

but my catch is not getting run. However this is the only line that I change that gives me this error so maybe the exception is thrown somewhere else?. How do I know where as anyone had this problem before?.

Chris
 
Try catching (Exception e) then on the try part use System.out.println (e.getMessage ()) to have a better clue.

Like yhis

try { ... }
catch (Exception e) {
System.out.println (e.getMessage ());
}


also check the size of the image you'll use something like
4 Mbytes for the image.



Daniel.Barreto@Netc.pt
 
Their is a limit to how much memory that Java Runtime Files can use on your class. I found this out and the java options allow you to increase the memory size. I would have to look up the article so send me a email if you want more info...........

good luck

 
those are the VM parameters

set it in your app: -XMS256M

this will expand the available memory up to 256MB.
 
I'd try with a smaller image,maybe the memory is being consumed elsewhere.

Anyway, if you want to catch that, it's an Error, not an Exception, you'd need to catch Throwable, not Exception. But catching an Error uses to be a not very good practice.

Cheers,

Dian
 
Guys - this post is 4 years old - try to leave the dead posts alone - they are sleeping !

--------------------------------------------------
Free Database Connection Pooling Software
 
... rock-a-bye 'Java Thread' on the tree top,
when the wind blows the forum will rock ...
when the thread break the Java will fall ...
down will come Java , Tak-Tips and all.


Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top