I have a bufferedImage in Java. How do I see how much memory it takes up? Thanks in advance.
You can determine how many bytes the image data alone takes up using this:
DataBuffer buff = image.getRaster().getDataBuffer();
int bytes = buff.getSize() * DataBuffer.getDataTypeSize(buff.getDataType()) / 8;
The image itself takes up a bit more space for the color model and other bookkeeping info, but for large images, bytes
will be the dominant term.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With