Originally posted by leandro oliveira:
guys, I've requested this page many times, and what I could notice was that for each request, tomcat 5.0 created a new instance of this page. Last night I did 4600 requests to this resource and 4600 objects were created, my memory usage increased linearly... I'm afraid of using singleThreadModel in a highly visited aplication, since we may have OutOfMemoryError...
Originally posted by leandro oliveira:
guys, I've requested this page many times, and what I could notice was that for each request, tomcat 5.0 created a new instance of this page. Last night I did 4600 requests to this resource and 4600 objects were created, my memory usage increased linearly... I'm afraid of using singleThreadModel in a highly visited aplication, since we may have OutOfMemoryError...
Hi,
I think you wanted to use this construct
<%
!{qtdInstances++;}%>
Note the ! in <%! to make it an instance initializer. Without !, it is just a scriplet (part of the _jspService method) that will be executed for each request, hence the high value printed by <%=qtdInstances%>
Also, as Michael suggested, you probably don't want to use isThreadSafe or SingleThreadModel at all. That interface is depricated in the new version of the specs.