[ 
https://issues.apache.org/jira/browse/WICKET-2846?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12888729#action_12888729
 ] 

Erik van Oosten commented on WICKET-2846:
-----------------------------------------

Juliano Viana on the WIcket user mailing list at 2010-07-14 15:55 wrote:

Hi everyone,

I know this issue has already been debated and that a decision was made to
revert this change in a future version of Wicket.
However, the discussions about this issue were centered on the fact starting
threads in web applications is not a good idea anyway, and hence this would
not break applications that are not already broken.
I have found a real case where this breaks an innocent application:
redeploying an application based on  Wicket 1.4.9 on Glassfish 3.0.1 causes
a memory leak due to the use of InheritableThreadLocal.
The problem is that when the application accesses a JDBC resource for the
first time, Glassfish lazily starts a timer (connector-timer-proxy) that has
an associated thread. This timer is started  from the web request processing
thread. This thread never dies, and inherits a reference to the Wicket
Application object.
This only happens on redeployments, but it really hurts development as you
keep having to restart Glassfish due to OOM exceptions.
Removing the InheritableThreadLocal resolves the issue completely and makes
development really smooth again.
So if you are using Wicket 1.4.9 with Glassfish v3 you should consider
patching it until a new Wicket release is out.

Regards,
  - Juliano


> Store Application in InheritableThreadLocal instead of ThreadLocal
> ------------------------------------------------------------------
>
>                 Key: WICKET-2846
>                 URL: https://issues.apache.org/jira/browse/WICKET-2846
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Alexandru Objelean
>            Assignee: Jeremy Thomerson
>            Priority: Minor
>             Fix For: 1.4.10
>
>         Attachments: wicket-application-leak.tar.gz
>
>
> Is there any particular reason why Application class wouldn't be stored in 
> InheritableThreadLocal instead of ThreadLocal? The problem is that I need to 
> be able to access Application class from a thread created when a button is 
> pressed. Using InheritableThreadLocal instead of ThreadLocal would solve 
> this problem. 
> Use case example:
> public class MyPage extends Page { 
>   @SpringBean 
>   private MyService service; 
>   //perform a polling of long running process triggered by a button click 
>   onClickButton() { 
>     new Thread() { 
>       run() { 
>         service.executeLongRunningProcess(); 
>       } 
>     }.start();   
>   } 
> } 
> The following example won't work well if the Application is not stored in 
> InheritableThreadLocal. The reason why it doesn't work, as I understand that, 
> is because @SpringBean lookup depends on Application instance which is not 
> accessible from within the thread. Having it stored inside of ITL would solve 
> the problem. 
> Thanks!
> Alex

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to