The memory requirement by SJSXP for small XML messages is high relative to the
size of the message.
For small messages (around 500 bytes), there is in excess of 60x memory
overhead. Most of this overhead comes from two buffers:
- the buffer used to hold bytes from the initial InputStream.
- the buffer used to hold decoded XML (e.g. in the UTF8Reader).
I'm not entirely sure why the first buffer is needed at all but nevertheless
both buffers' initial size is 8192. Given that the second buffer is a char,
these buffers alone take up around 25K which is significant when the messages
There is the following comment in the source code:
- Buffer size. We get this value from a property. The default size
- is used if the input buffer size property is not specified.
- REVISIT: do we need a property for internal entity buffer size?
I think it would be a good enhancement to reduce the default buffer size when
messages are really small.
This could be done in three ways:
- through a system property (perhaps a bit too coarse grained but useful for
running performance tests).
- through a property on the factory (good since it can be specific to a piece of
functionality in which the XML messages are around the same size).
- adaptive, i.e. learns based on message sizes (requires some kind of
As a start, I think it would be good to provide the first two options out of the