title: Possible Apple JVM bug: java.lang.OutOfMemoryError: Java heap space at apple.awt.CRobot.getRGBPixels(CRobot.java:204)
body: <p>I'm having issues when I take screenshots. This is my test code.</p>
  
  <pre><code>import java.awt.Robot;
  import java.awt.AWTException;
  import java.awt.image.BufferedImage;
  import java.awt.Rectangle;
  import java.awt.Toolkit;
  import java.awt.Dimension;
  
  public class Test {
          public static void main(String[] args) throws AWTException {
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              int[] pixels = new int[(int) (screenSize.getWidth() * screenSize.getHeight()) * 3];
              Robot robot = new Robot();
              int i = 0;
  
              while (true) {
                  robot.createScreenCapture(new Rectangle(screenSize))
                       .getRaster().getPixels(0, 0, (int) screenSize.getWidth(), (int) screenSize.getHeight(), pixels);
                  System.out.println(++i);
              }
          }
  }
  </code></pre>
  
  <p>On my Mac*<em>s</em>* with OS X 10.6.4 and Java 1.6.0_20-b02-279-10M3065 it fails after two iterations. It seems to work fine on Windows. Can you reproduce this behaviour?</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at apple.awt.CRobot.getRGBPixels(CRobot.java:204)
        at java.awt.Robot.createScreenCapture(Robot.java:329)
        at Test.main(Test.java:16)</p>
  </blockquote>