[
https://issues.apache.org/jira/browse/DIRECTMEMORY-84?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13283798#comment-13283798
]
Jeff MAURY commented on DIRECTMEMORY-84:
----------------------------------------
In fact, it is a little bit more subtle. The servlet spec guaranties that for a
servlet definition, there will be a single instance in a JVM (assumed it is not
a SingleThreaded servlet, btw SingleThreaded pattern is probably the sole PHP
piece of code in the Java ecosystem). So I think we don't need a
ContextListener. But I have discovered that Tomcat is calling twice the servlet
init method !!! so we should probably protect against this double call (this
seems to be a very old Tomcat behavior). You can see in the Maven log that the
servlet traces are generated twice in a sequence and on the same thread.
> Cache should not be a private DirectMemoryServlet field and initialized in
> init methods
> ---------------------------------------------------------------------------------------
>
> Key: DIRECTMEMORY-84
> URL: https://issues.apache.org/jira/browse/DIRECTMEMORY-84
> Project: Apache DirectMemory
> Issue Type: Bug
> Components: REST Server
> Affects Versions: 0.6.0
> Reporter: Jeff MAURY
> Labels: REST, memory_leak
> Fix For: 0.6.0
>
>
> The cache should not be a private DirectMemoryServlet field as there is
> nothing per the Servlet spec that prevents the Servlet container to hold
> several instances of the same servlet class. This may lead to memory
> consumption (as the cache may be created several times) and unexpected
> behaviour (as one instance may put the object in ITS cache and another one
> try to retrieve it and either no finding it or returning another object !!!!).
> It should be a Servlet context attribute and managed through the
> ServletContextListener pattern.
> As soon as I have completed the work i'm doing on the Closeable stuff, I'm
> will submit the fix
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira