Details
-
Suggestion
-
Resolution: Fixed
-
None
-
None
Description
Each time a sitemesh decorator is applied in Confluence, the content of that decorator is buffered not once but three times. Here is some example offending code:
StringWriter bodyBuffer = new StringWriter(); page.writeBody(OutputConverter.getWriter(bodyBuffer)); context.put("body", bodyBuffer.toString());
So we have:
- The original sitemesh page buffer
- The StringWriter buffer (which as it grows will copy itself many times over)
- The character array in the String array produced by the bodyBuffer
This happens several times per request, once for the main page and several times as various components use the #applyDecorator velocity directive.
This need not be the case, velocity has a Renderable interface, that allows you to write directly to velocities writer, without buffering the page into a String, so that each time a decorator is applied, the content is only buffered once.