users@jersey.java.net

[Jersey] Re: PermGen Memory Leak in Tomcat

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Mon, 17 Oct 2011 10:19:31 +0200

Hi John,

It depends on what container you use, what message body readers/writers
and how many re-deployments you do. The original reporter run out of
PermGen space,
which is of course a serious issue, but this should only happen
if you rely on particular XML related stuff and redeploy feature.
Thread local variables used by Jersey in the request scope are being
cleaned up properly,
so if you just deploy once and keep running, the issue should not have a
great impact on you.
It also should not impact you at all when running on Grizzly and other
low level embedded
containers.

HTH,

~Jakub



On 15.10.2011 17:34, John G. Lussmyer wrote:
> Just how much will this matter to most jersey users?
> How often is an undeploy normally done?
> (I'm trying to figure out if this will impact my products noticeably.)
>
> On 10/11/2011 7:59 AM, Jakub Podlesak wrote:
>> Hi Stephen,
>>
>> I am afraid Jersey does not remove it's thread locals
>> and there is currently no way to force Jersey to clean up properly.
>> We need to fix that.
>>
>> Could you please file a bug report [1] to track this?
>>
>> Thanks,
>>
>> ~Jakub
>>
>> [1]http://java.net/jira/browse/JERSEY/
>>
>> On 29.9.2011 12:56, DaveCrystal wrote:
>>> Hello, I am using Jersey 1.9.1 with spring to create a rest web service
>>> hosted in Tomcat.
>>>
>>> The application follows the pattern in this example.
>>> http://blogs.oracle.com/enterprisetechtips/entry/jersey_and_spring
>>>
>>> When the web application is undeployed Tomcat logs a warning that the
>>> application has created a ThreadLocal and not removed it:
>>>
>>> SEVERE: The web application [/sandbox] created a ThreadLocal with
>>> key of
>>> type [null] (value
>>> [com.sun.jersey.core.impl.provider.xml.ThreadLocalSingletonContextProvider$1_at_])
>>>
>>> and a value of type
>>> [com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl] (value
>>> [com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl_at_f76983])
>>> but
>>> failed to remove it when the web application was stopped. This is very
>>> likely to create a memory leak.
>>>
>>> After deploying and undeploying the app several times Tomcat runs
>>> out of
>>> PermGen space.
>>>
>>> Any advice on how I can cause Jersey to clean up the Thread Locals on
>>> undeploy would be much appreceiated.
>>>
>>> Thanks a lot.
>>>
>>> --
>>> View this message in context:
>>> http://jersey.576304.n2.nabble.com/PermGen-Memory-Leak-in-Tomcat-tp6843479p6843479.html
>>> Sent from the Jersey mailing list archive at Nabble.com.
>>>
>>
>
>