In Java, I have encountered an OutOfMemoryError due to the use of a BufferedImage. When I printed to the console how much memory was being used by that BufferedImage alone (in bytes), I noticed that he number of bytes being used increased exponentially. My results were as such:
7396
12996
23104
40804
71824
125316
217156
372100
630436
1060900
1763584
2903616
4726276
7595536
12054784
18887716
29181604
44435556
66650896
98446084
143089444
204547204
-249500608
-140383168
I used the following code to produce my result:
while (true) {
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
DataBuffer buff = img.getRaster().getDataBuffer();
System.out.println(buff.getSize() * DataBuffer.getDataTypeSize(buff.getDataType()) / 8);
}
Why is this increase so great and how can I keep this increase from happening? Also, what does it mean when there is a negative sign in front of the number (the last 2)?
EDIT:
Note that width and height change constantly, but I wouldn't expect them to increase (Sorry)