[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 727
  • Last Modified:

Help! (0x80004005) Unspecified error

Hi, all!

I got the following error when I was using the Component.createImage() method. My code looks like this:

 private updateImg() {
   Image offScrImg = null;
   offScrImg = this.createImage(width,height);
   Graphics g = offScrImg.getGraphics();

   g.drawString(...);//draw string to offScrImg
   g.drawImage(....);//draw image to offScrImg
   
   g = this.getGraphics();
   g.drawImage(offScrImg....);
 }

The above method is called each time the user need to see new information, and so that the method createImage() may be called many times. The following exception was not always occurring. Instead, it occurred randomly after many calls to the updateImg() method.
I cannot figure out what's wrong with my code since the error comes from the createImage() method.. I hope someone can help me to solve this problem. Or if cannot, I hope I can have an alternative method that can do the thing I want, yet not using the createImage() method.

// the exception...
Exception occurred during event dispatching:
com.ms.com.ComFailException: (0x80004005) Unspecified error

      at com/ms/awt/peer/INativeImage.create (INativeImage.java)
      at com/ms/awt/image/ImageRepresentation.offscreenInit (ImageRepresentation.java)
      at com/ms/awt/image/Image.<init> (Image.java)
      at com/ms/awt/ImageX.<init> (ImageX.java)
      at com/ms/awt/WComponentPeer.createImage (WComponentPeer.java)
      at java/awt/Component.createImage (Component.java)


Thank you very much!!

Yours sincerely
Zicai - Now in the HELL..      
0
zicai
Asked:
zicai
  • 5
  • 4
  • 2
  • +1
1 Solution
 
JodCommented:
Well microsoft says this:

http://www.microsoft.com/java/sdk/32/start.htm?http://www.microsoft.com/Java/sdk/32/packages/ref_com1_package_24.htm

which basically says the error is unspecified. Very useful...

Perhaps it is a memory or resources problem, because of the unpredictable pattern of failure.

Try

:

 private updateImg() {
   Image offScrImg = null;
   offScrImg = this.createImage(width,height);
   Graphics g = offScrImg.getGraphics();

   g.drawString(...);//draw string to offScrImg
   g.drawImage(....);//draw image to offScrImg
   
   g = this.getGraphics();
   g.drawImage(offScrImg....);
   // set image resources to null
   offScrImg = null;
 }

and forcing the occasional garbage collection to see if this helps.

Do you get the source files so can you see inside this java file:

INativeImage.java

to see what it is doing in the

INativeImage.create

to cause it to crash?
0
 
heyhey_Commented:
in many JavaVM Win implementations some native resources (Imageand Dialogs for example) are never returned to the OS ... so you'll sooner or later crash the VM / OS.

the only answer is: recycle.
reuse all your Objects.

create only one offscreen image and use it all the time.
0
 
zicaiAuthor Commented:
Hi,

Jod, I had tried the method which set the offScrImg to null right after I finished use it, but it only helped me to delay the apperence of the error, but not eliminate the chance of the error... I'll visit the web page you told me to see whether there are any information that will help.

Heyhey, I had thought it is better to declare variables for each method and pass them around rather than to declare them as gloable.. And also I don't quite understand "never returned to the OS". Can you explain it more clearly? Later today I'll try to reuse the offscrImg and see whether it can solve my problem.

Thank you very much!!
Yours sincerely
Zicai - wondering why you guys know so much..about..
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
heyhey_Commented:
because of bugs, some JavaVM may request some native resources (Offscreen image space for example) and never return these resources to the OS and since OS has limited resources, sooner or later your VM will 'crash'.

as far as I remember this problem was inside Top10 Bugs at www.javasoft.com, but it seems that it is supposed to be fixed for 1.22 / 1.3 or whatever is the last Sun's JavaVM version ...
0
 
zicaiAuthor Commented:
Hi, heyhey

If I need to change the size of the offscreen image, what shall I do? Actually, I am trying to do some scrolling. What I have done is to detect the size of the workspace, then create an offscreen image according to that size, and then draw this offscreen image to the display area with different starting point to realize the scrolling effect...
Any suggestions from you?


Yours sincerely
Zicai
0
 
zicaiAuthor Commented:
Hi again..

Where can I find the java bugs' list?
I cannot locate a list at www.javasoft.com...
Maybe you can post an entire url here

Thanks!
0
 
heyhey_Commented:
hmmm ... you can create one big offscreen image ... as big as possible :)
I usually recreate the offscreen image, only when I need bigger drawing area that the previous image.

Java Bug Parade
http://developer.java.sun.com/developer/bugParade/index.jshtml
(free subscription required)

it seems that Top25 bugs list does not work at the moment ...

and here is your bug - there are several thing that you can try (take a look at the comments)
http://developer.java.sun.com/developer/bugParade/bugs/4014323.html
Bug Id 4014323
Votes 461
Synopsis Java Image memory leaks

btw. what happend with your list component ? :)
0
 
zicaiAuthor Commented:
Hi, heyhey

I had read the bug report.. unfortunatelly, I am not to use Java 1.2.. Maybe I'll try to create one big enough image to do the job.

About the list component, currently I am still using my own method.. My project has already run out of time, and I don't have time to think more about the list component now.

Oooooppss..

Yours sincerely
Zicai - looking for strong shoulders..
0
 
heyhey_Commented:
there are several good proposals / comments inside the Bug page (call image.flush() etc.)
0
 
JodCommented:
hi zicai,

I think the bug that heyhey_ has given you the link to is your answer - it does appear to be a resources problem but there is lots of good info in the workaround and the evaluation of the bug to help with avoiding the problem.

We have had a similar, though not the same problem, with components eating memory over time and so you are not alone.

Looks like Sun have taken their time to fix this one.

Good luck...
0
 
Ravindra76Commented:
I also think same too
0
 
zicaiAuthor Commented:
Hi!

I was sick for some days, so I didn't come here for quite some time..
Now I tried to create one big image and use it through out the progrom, and seems there's no more trouble. So I accepted heyhey's comment as the answer:) At the same time, many thanks to the rest people who commented on this problem.


Thank you!
Yours sincerely
Zicai
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 5
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now