Thanks for ur reply ..
I tried that ...i guess my question would be how to INCREASE the Total
Memory or free memory ...even after using the garbage collection method the
freee memory available is not sufficeint enough to do what my program
intends to do ..again remember i can't use the -mx option as the java
command is no where used

Also what units are the following # s in ?bytes?
Total Memory is 2199544
Initial Free Memory is 1174592
After Garbage Collection, Free Memory is 1295048

Please help

Thanks

-----Original Message-----
From: Michael Thompson [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 30, 2000 11:58 AM
To: 'Mokashi, Swanand'
Cc: '[EMAIL PROTECTED]'
Subject: RE: [JAVA2D] java.lang.OutOfMemoryError: WITH Toolkit




<grin>
welcome to the world of java.  pointers need not apply ...
</grin>



use of 'new' verb will allocate the required memory.

but if you need feedback on memory or resources remaining, use the following
example:


//
//      memory usage example below ...
//
Runtime r = Runtime.getRuntime ( );

long totalMem = r.totalMemory ( );
System.out.println ( "Total Memory is " + totalMem + "\n" );

long freeMem = r.freeMemory ( );
System.out.println ( "Initial Free Memory is " + freeMem + "\n" );

/*
 *
 *      do some java memory stuff here ...
 *
 */

freeMem = r.freeMemory ( );
System.out.println ( "After Some Java Memory Stuff, Free Memory is " +
freeMem + "\n" );

r.gc ( );       //      do some garbage collection ...
freeMem = r.freeMemory ( );
System.out.println ( "After Garbage Collection, Free Memory is " + freeMem +
"\n" );

//
//      end of example ...
//






-----Original Message-----
From: Mokashi, Swanand [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 30, 2000 7:13 AM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA2D] java.lang.OutOfMemoryError: WITH Toolkit


Since I am using a bean to create thumbnails as a part of a web project teh
mx options is not applicable?
I thought memory allocation is auto in Java ...am I missing something ? I
could not find anywhere how to allocate memory in Java ??

Please help!

-----Original Message-----
From: Irving Salisbury [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 28, 2000 7:02 PM
To: Mokashi, Swanand
Subject: Re: [JAVA2D] java.lang.OutOfMemoryError: WITH Toolkit


You can get an OutOfMemory error because you are trying to allocate more
memory
than the VM currently has available.  Of course, the VM is not smart enough
to
garbage collect and then try it again.  This is a very common thing that
happens
with large single allocations.  I use the following:

try {
    // huge allocation
}catch( OutOfMemoryError e ){
    Runtime.getRuntime().gc();
    Runtime.getRuntime().runFinalization();
    // try huge allocation again
}

If there really is enough memory, this will work.  We have a large imaging
system we have written, and have this code peppered a lot of places.

Irv

"Mokashi, Swanand" wrote:

> I am trying to load an image using the Toolbox class provided with the
book
> " Java 2d API Graphics " by Vincent Hardy. The Toolbox class basically
> implements the Toolkit class
>
> I am trying to load an image with
> image = Toolbox.loadImage(imageName, BufferedImage.TYPE_INT_RGB);
>
> This works great with small images (in memory size) ..However for large
> images this fails and gives these errors :
>
> java.lang.OutOfMemoryError:
> at
sun.awt.image.ImageRepresentation.setPixels(ImageRepresentation.java:468)
> at sun.awt.image.ImageDecoder.setPixels(ImageDecoder.java:127)
> at sun.awt.image.JPEGImageDecoder.sendPixels(JPEGImageDecoder.java:124)
> at sun.awt.image.JPEGImageDecoder.readImage(Native Method)
> at sun.awt.image.JPEGImageDecoder.produceImage(JPEGImageDecoder.java:150)
> at
>
sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:248
> )
> at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:221)
> at sun.awt.image.ImageFetcher.run(ImageFetcher.java:189)
> ServletExec.ProcessRequest() error: java.lang.OutOfMemoryError:
> java.lang.OutOfMemoryError:
> at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:48)
> at java.awt.image.Raster.createPackedRaster(Raster.java:404)
> at
>
java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorMo
> del.java:637)
> at java.awt.image.BufferedImage.<init>(BufferedImage.java:245)
> at com.sun.glf.util.Toolbox.loadImage(Toolbox.java:209)
> at com.sun.glf.util.Toolbox.loadImage(Toolbox.java:184)
> at swanand.ImageSize.<init>(ImageSize.java:23)
> at
>
ImageManipulation.OffscreenBufferRendering.Manipulate(OffscreenBufferRenderi
> ng.java:84)
> at
>
pagecompile._imagemanipulation._default_xjsp._jspService(_default_xjsp.java:
> 54)
> at newatlanta.servletexec.JSP10HttpJspPage.service(JSP10HttpJspPage.java)
> at newatlanta.servletexec.JSP10Servlet.service(JSP10Servlet.java)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
>
> Please help !!
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff JAVA2D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to