It is an interesting finding to answer the question in the title.
Today, I try put my software to its edge. I create a Display with W=1024 and H=180,000 pixels. Then an OutOfMemeoryException was thrown.
At first, I thought the data is too big to fit in the main memory. So I checked the memory usage, which showed that I didn't reach the maximum memory, and only 60% of the max memory was used. Then I tried to google the origins of the OutOfMemoryException. Some similar links popped up. It turns out to be an issue about the largest size of a BufferedImage that a JVM can located. Here is my findings.
- In Prefuse, Display is the "canvas" allowing a Visualization to paint on. Its source codes show that, a Display uses a BufferedImage to create the Graphics2D for Visualizations.
- So how large can a BufferedImage be? A BufferedImage is a combination of a 2D int array, which indicate the X-Y coordination, and a 1D of colors, which indicate the color in each X-Y pixels. Therefore,
the size of a BufferedImage = int[][] * a color
- Theoretically, the largest size of an int[][] = the largest size of an int[], which Max2D array = Max1D array = 2^32B in JAVA. An integer will take 32 bits = 4 Bytes.
- A color in Java2D is a 32 bits number, with each Byte represent 0-255, for RGB color and a an alpha value for transparency. So a color takes 32 bits = 4Bytes;
Notices: the Max2D array could be limited by the VM in your machine and the max memory you located for your application. So the final max dimension of a display could vary from one machine to another machine.


