Skip to Main Content

occasional "lag" in drawImage

843807Jun 1 2010 — edited Jun 2 2010
Hi,

my problem is, that sometimes the drawImage function needs way more time than it should. It only seems to happen at my computer which makes this hard to troubleshoot. So far the problem has not occured anywhere else.

I'm simply drawing small tile images (64x48) in a JPanel's paintComponent. After adding a TimeMeasurement this is what the code looks like:
TimeMeasurement drawImage=new TimeMeasurement("drawImage");
g.drawImage(tile, xDrawAt, yDrawAt, null);
drawImage.end();
The result of the TimeMeasurement is this:
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 16ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 16ms
  drawImage: 15ms
  drawImage: 16ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
  drawImage: 0ms
As you see it just sometimes takes 16ms while it generally takes 0ms, without any pattern. The images are all similar (pre-loaded subparts of a bigger one) and as I've mentioned before this only happens on my PC (which is a lot more powerful than others on which it runs smoothly).

I have Java 6 on Windows XP. I could go more into details here if necessary.

I realise that this might be a hard question to answer but I'm pretty clueless about what's causing this, so any ideas would help.

regards lukar
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on Jun 30 2010
Added on Jun 1 2010
6 comments
500 views