[
https://issues.apache.org/jira/browse/SLING-5117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14947373#comment-14947373
]
Carsten Ziegeler commented on SLING-5117:
-----------------------------------------
I don't remember the details, but the thread local was never cleared at the end
of the request, creating in some situations a large memory leak.
On the other hand, I'm not sure if we can really switch to a cached page local,
as the request can be handled by any number of scripts, even different script
languages can be mixed. I have no idea what the jsp spec says about
includes/forwards and the page context object. That would be checked as well.
For the on demand stuff, I haven't checked but I'm pretty sure we need them.
Maybe it's for the case where one is using the output stream and not the print
writer in a jsp? As different jsps/scripts can be used, the usage can be mixed
> Reuse PrintWriter to avoid initialisation overhead
> --------------------------------------------------
>
> Key: SLING-5117
> URL: https://issues.apache.org/jira/browse/SLING-5117
> Project: Sling
> Issue Type: Improvement
> Components: Scripting
> Reporter: Joel Richard
> Priority: Minor
> Labels: performance
>
> Surprisingly, java.io.PrintWriter is relatively expensive to initialise
> because of the AccessController.doPrivileged call in the constructor. Right
> now, it initialises for each include a new PrintWriter which costs 2-3%
> rendering time.
> In order to avoid this overhead, I would suggest to fix SLING-1284 properly
> (as far as I have seen there is a real fix in Tomcat) and create a reusable
> PrintWriter in PageContextImpl together with the JspWriter. In addition, the
> OnDemandWriterResponse must be adjusted to not create a new PrintWriter.
> Maybe, all the OnDemand* classes could also just be removed.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)