title: ImageIcon loading getting slower and slower
body: <p>In my java GUI application, I have some components that need to scale repeatedly, and I am doing this with the following code:</p>
  
  <pre><code>Image newImage = myimage.getScaledInstance(width, height, Image.SCALE_REPLICATE);
  
  ImageIcon newIcon = new ImageIcon(newImage);
  
  this.setIcon(newIcon);
  
  this.setSize(width,height);
  
  //increment width, height
  </code></pre>
  
  <p>At first this works fine, but after many iterations (a couple hundred) the new ImageIcon() constructor is taking an inordinate amount of time (about 1 second), based on some simple time checks.  The rest of the code is speedy.</p>
  
  <p>Why does this happen after many iterations, and how can I make it stop slowing down as iterations increases?  (Loading the images in a background thread won't work, because loading the images is not a constant-time operation).</p>