Hi Jim,

In the last 12 hours, I've found out a lot of interesting stuff.  I wish I 
could sit in your office and explain it all.  Email has limits...

But to summarize -- I solved the conundrum of how to gracefully exit from an 
OOME.

I put the call to pg.grabPixels(long n) in a separate thread -- pgThread -- 
then I loop on pgThread.isAlive().  pgThread() stays alive even though 
grabPixels() is wait()'ing for ImageFetcher to notify() it.  However, the 
PixelGrabber object is still alive and well and ImageFetcher does set the state 
to IMAGEERROR in pg,ImageComplete().  Each time through the pgThread.isAlive() 
loop, I simply check the error state.  If there is an error, I notify both the 
PixelGrabber and the pgThread.

It all comes unwedged at that point and I am able to catch Throwables in 
various places and eventually end up right where I want to.

I am sending you the complete source to MY class -- in a separate email -- that 
does my image fetching and image creation and pixel grabbing so you can have a 
better idea of what I did.  It's messy.  But I want you to see the whole thing 
before I clean it up.

Here is an EXECUTION trace -- not a stack trace.  I printout information so I 
can watch the execution.

APPLET
PanCyl v0.1h
INIT
getImageBytes()...
makeImageFromToolkit()...
START
loadImage(images/Room.jpg)
run()...
getImageBytes()...
makeImageFromToolkit()...
getImageParametersAndPixels()...
pgThread alive...
status = 0
ts = RUNNABLE
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap 
space
pgThread alive...
status = 192
ts = RUNNABLE
isAlive: image fetch aborted or errored
(1)Throwable: getImageParametersAndPixels()...
Grabbing Pixels Failed...
(2)Throwable: getImageParametersAndPixels()...
STOP
DESTROY...

I suspect that the reason why you wrote MediaTracker is the same reason why 
PixelGrabber will wedge.  I suspect that this has to do more with the native 
threads than the Java JVM.

Ken

===========================================================================
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