问题
MTOM is usually used to transfer image data over SOAP (attachments). The image is mapped to a java.awt.Image (at least with CXF). Does the Image object consume a lot more memory than the actual image transferred? Let's say a transferred JPEG is 10MB, how much more space will the Image object consume?
- UPDATE - I'm not so sure it has anything to do with java.awt.Image at all. Focusing on CXF/MTOM more at the moment: http://cxf.547215.n5.nabble.com/MTOM-large-attachments-eating-up-JVM-heap-td5714196.html
回答1:
Does the Image object consume a lot more memory than the actual image transferred?
Typically yes. The idea of most of the file formats is to compress image data.
Let's say a transferred JPEG is 10MB, how much more space will the Image object consume?
The RAM size depends on W * H * 'pixel depth'. E.G. RGBA in 256 shades is 4 bytes per pixel. JPEG does not support alpha transparency, so it would be 3 bytes per pixel.
For some idea of the effectiveness of JPEG compression efficiency at different levels, see this answer:

来源:https://stackoverflow.com/questions/12489009/how-much-memory-will-java-awt-image-consume-if-jpeg-is-10mb