Look at the ThreadLocal source and you'll see it stores all your 
ThreadLocal objects in what basically amounts to hash map of weak 
references.  The reason set(null) is called is that since it's assumed that 
Servlet instances/threads are being re-used to handle incoming requests, 
since that's how containers are supposed to do it, you can avoid the bit of 
overhead of fully removing the whole thread id key and map value done in 
remove() by just nulling out the thread local value associated with the 
thread id.

Since ThreadLocal uses a weak reference for the keys of its internal 
ThreadLocalMap too, even if your servlet threads are eventually killed off 
and replaced by new threads they and their thread locals should be able to 
be garbage collected.

I would see if you dig deeper and see what that thread local map is 
actually storing (jmap / jhat are your friends), perhaps your persistence 
or injection framework is leaving behind thread locals, I don't think it's 
GWT's remote service servlet though.


On Tuesday, November 27, 2012 5:04:20 AM UTC-6, Shawn wrote:
>
> I can't see an issue with AbstractRemoteServiceServlet but ... am I 
> missing something?
>
> Well OK I don't understand why the call is perThreadRequest.set(null) and 
> NOT .remove()
>
> *remove<http://docs.oracle.com/javase/6/docs/api/java/lang/ThreadLocal.html#remove()>
> *() 
>           Removes the current thread's value for this thread-local variable
>
> *set<http://docs.oracle.com/javase/6/docs/api/java/lang/ThreadLocal.html#set(T)>
> *(T <http://docs.oracle.com/javase/6/docs/api/java/lang/ThreadLocal.html>
>  value) 
>           Sets the current thread's copy of this thread-local variable to 
> the specified value.
>
>   Are the 400.000 entries null and if so is that taking memory???
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/uSER0PIy9coJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to