Re: OutOfMemoryError: PermGen space - SOLVED

2016-07-25 Thread Mark Eggers
Cris,

On 7/25/2016 6:17 AM, Berneburg, Cris J. - US wrote:
> Mark (Eggers)
> 
> -Original Message- From: Mark Eggers
> [mailto:its_toas...@yahoo.com.INVALID] Sent: Friday, July 22, 2016
> 1:28 PM To: Tomcat Users List Subject: Re: OutOfMemoryError: PermGen
> space - SOLVED
> 
>> Cris,
>> 
>> On 7/22/2016 10:15 AM, Berneburg, Cris wrote:
>>> Mark (Thomas), Román, Guido, and Mark (Eggers)
>>> 
>>> Thank you all for your suggestions, assistance, and patience.
>>> 
>>> With your help and encouragement I learned how to perform heap
>>> dumps using Java VisualVM, analyze them using Eclipse Memory
>>> Analyzer, and follow instructions.  ;-)
>>> 
>>> [SNIP]
>>> 
>>> I apologize for taking your time and bandwidth on such a newbie 
>>> mistake.
>>> 
>>> Thanks again for your help.  :-)
>>> 
>>> -- Cris Berneburg CACI Lead Software Engineer
>>> 
>>> [SNIP]
>>> 
>>>> Here's the error:
>>>> 
>>>> FAIL - Application at context path /someapp could not be
>>>> started FAIL - Encountered exception
>>>> java.lang.OutOfMemoryError: PermGen space
>>>> 
>> 
>> You're more than welcome. Glad that it was a simple 'read and
>> follow the instructions' problem. Been there, done that, have the
>> palm prints on my forehead.
> 
> I read those Log4J instructions previously
> (https://logging.apache.org/log4j/2.x/manual/webapp.html) but failed
> to notice/remember the bits about the listener and filter.  Sometimes
> I think what happens is that I am so overwhelmed by implementing
> something new to me, with all its complexities, that I miss an
> important detail.  Then afterwards it doesn't seem as complex any
> more.
> 
>> Something I've made a habit of (after getting burned several times
>> by stray threads, threadlocals, and permgen errors) is to search
>> for tomcat / servlet container in the context of using a library
>> when I add a new one to the mix.
>> 
>> That search has saved me lots of grief.
> 
> Would you please explain that?  Do you search through your own source
> code or source code of the new library?
> 
> -- Cris Berneburg CACI Lead Software Engineer
> 

First of all, I'm more of a systems / software architect than a
developer. Since I'm not a diagram-only architect, I do some
development. However, that's mostly proof-of-concept to make sure I
don't create unworkable systems.

For a variety of reasons, I'm moving the company I provide consulting
services to towards Maven. On occasion, the software they develop
requires new functionality. Since they're relatively small, I've
encouraged the use of third party libraries.

Using third party libraries requires a bit of vetting. I'll not go into
detail here (security, liveliness of project, health of community,
fitness of purpose, etc.), but one of the things I search for is how
well does that library play in a servlet container.

Google searches (pick your favorite search engine) are helpful. For
example, here are some searches for the gson library:

gson threadlocal
gson permgen
gson servlet container
gson tomcat
gson memory leak tomcat

If you do these searches, you'll find out that earlier versions of the
gson library had a threadlocal issue which led to a permgen memory leak.

While the initial response from the project was not encouraging
(actually quite discouraging), the issue was finally fixed.

jackson (used as the JSON serialization library in Jersey REST) seems to
have had similar issues at one point.

While the above searches won't catch everything, they do serve as good
starting points.

That plus visualvm (or YourKit or Eclipse MAT) are your friends.

. . . just my two cents
/mde/



signature.asc
Description: OpenPGP digital signature


RE: OutOfMemoryError: PermGen space - SOLVED

2016-07-25 Thread Berneburg, Cris J. - US
Mark (Eggers)

-Original Message-
From: Mark Eggers [mailto:its_toas...@yahoo.com.INVALID] 
Sent: Friday, July 22, 2016 1:28 PM
To: Tomcat Users List
Subject: Re: OutOfMemoryError: PermGen space - SOLVED

> Cris,
> 
> On 7/22/2016 10:15 AM, Berneburg, Cris wrote:
> > Mark (Thomas), Román, Guido, and Mark (Eggers)
> > 
> > Thank you all for your suggestions, assistance, and patience.
> > 
> > With your help and encouragement I learned how to perform heap dumps 
> > using Java VisualVM, analyze them using Eclipse Memory Analyzer, and 
> > follow instructions.  ;-)
> > 
> > [SNIP]
> > 
> > I apologize for taking your time and bandwidth on such a newbie 
> > mistake.
> > 
> > Thanks again for your help.  :-)
> > 
> > -- Cris Berneburg CACI Lead Software Engineer
> > 
> > [SNIP]
> > 
> >> Here's the error:
> >> 
> >> FAIL - Application at context path /someapp could not be started FAIL 
> >> - Encountered exception java.lang.OutOfMemoryError: PermGen space
> >> 
>
> You're more than welcome. Glad that it was a simple 'read and follow the
> instructions' problem. Been there, done that, have the palm prints on my
> forehead.

I read those Log4J instructions previously 
(https://logging.apache.org/log4j/2.x/manual/webapp.html) but failed to 
notice/remember the bits about the listener and filter.  Sometimes I think what 
happens is that I am so overwhelmed by implementing something new to me, with 
all its complexities, that I miss an important detail.  Then afterwards it 
doesn't seem as complex any more.

> Something I've made a habit of (after getting burned several times by
> stray threads, threadlocals, and permgen errors) is to search for tomcat
> / servlet container in the context of using a library when I add a new
> one to the mix.
>
> That search has saved me lots of grief.

Would you please explain that?  Do you search through your own source code or 
source code of the new library?

--
Cris Berneburg
CACI Lead Software Engineer


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: OutOfMemoryError: PermGen space - SOLVED

2016-07-25 Thread Berneburg, Cris J. - US
Mark/T, Román, Guido, and Mark/DE

-Original Message-
From: Mark Thomas [mailto:ma...@apache.org] 
Sent: Friday, July 22, 2016 4:54 PM
To: Tomcat Users List
Subject: Re: OutOfMemoryError: PermGen space - SOLVED

On 22/07/2016 19:15, Berneburg, Cris wrote:
> > Mark (Thomas), Román, Guido, and Mark (Eggers)
> > 
> > [SNIP]
> > 
> > The OutOfMemoryError in Tomcat Manager was caused by a memory leak
> > when Log4J did not terminate properly.  This was due to my mistake
> > of neglecting to set up the necessary Log4J shutdown procedures.
> > 
> > Adding Log4jServletContextListener and log4jServletFilter to my
> > app's web.xml solved the problem.  The Find Leaks button on the
> > Tomcat Manager page confirmed.
> > 
> > I apologize for taking your time and bandwidth on such a newbie mistake.
> 
> No need to apologize. Glad we were able to help.

Thank you all for your gracious replies.  :-)

> Tracking down memory leaks is never easy and I would have said
> guiding someone how to do it via e-mail is close to impossible.
> I'm impressed at how quickly you managed to get this fixed.

Well, please don't be *too* impressed, OK?  ;-)  It was you (Mark Thomas) who 
posted how to find memory leaks and hinted at the Log4J shutdown procedures.  
Román suggested using Java VisualVM to grab heap dumps, and Guido recommended 
using Eclipse Memory Analyzer to analyze them.  Finally, it was Mark Eggers who 
posted the link to the Log4J page that detailed the very Log4J shutdown 
procedures I was missing.  You guys made it possible for me to solve my problem 
and saved me a lot of hassle by sharing your past and current experiences!

> As an added bonus we now have some great content in the archives to
> point people to when they are trying to track down memory leaks.

While I felt like I was in danger of flooding the discussion group with 
stream-of-consciousness writing of all the details I tripped over, the archives 
is what I had in mind for some poor soul in the future struggling through the 
same sort of issue.

Also me slightly bending the rules about top-posting: put a short intro at top 
with a BLUF (bottom-line up front) clause to save folks time who did not want 
details, and then full details embedded in the message below for anyone who 
cared to dig deep.

--
Cris Berneburg
CACI Lead Software Engineer


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: OutOfMemoryError: PermGen space - SOLVED

2016-07-25 Thread Berneburg, Cris J. - US
Hi Guido

-Original Message-
From: Guido Jäkel [mailto:g.jae...@dnb.de] 
Sent: Saturday, July 23, 2016 8:38 AM
To: Tomcat Users List
Subject: Re: OutOfMemoryError: PermGen space - SOLVED

On 22.07.2016 19:15, Berneburg, Cris wrote:

> > The OutOfMemoryError in Tomcat Manager was caused by a
> > memory leak when Log4J did not terminate properly.  This
> > was due to my mistake of neglecting to set up the
> > necessary Log4J shutdown procedures.
> > 
> > Adding Log4jServletContextListener and log4jServletFilter
> > to my app's web.xml solved the problem.  The Find Leaks
> > button on the Tomcat Manager page confirmed.
>
> Dear Chris,
>
> may you add here a short snipped of your additions to the
> web.xml, please? As Mark said, this may also a good and
> convenient reference for others.

Sure.  Please keep in mind this info may become stale as Log4J is maintained.  
At the time of publishing, Log4J was at version 2.6.2.

> From the log4j2 web site:
> 
> https://logging.apache.org/log4j/2.x/manual/webapp.html

[SNIP]

> you'll need to add the log4j-web module to your deployment [...]
> To avoid problems the Log4j shutdown hook will automatically be 
> disabled when the log4j-web jar is included.

[SNIP]

> If you are using Log4j in a Servlet 2.5 web application, or if you
> have disabled auto-initialization with the
> isLog4jAutoInitializationDisabled context parameter, you must
> configure the Log4jServletContextListener and Log4jServletFilter in
> the deployment descriptor or programmatically.

[SNIP]

[BEGIN BLOCK QUOTE]



org.apache.logging.log4j.web.Log4jServletContextListener



log4jServletFilter

org.apache.logging.log4j.web.Log4jServletFilter


log4jServletFilter
/*
REQUEST
FORWARD
INCLUDE
ERROR
ASYNC


[END BLOCK QUOTE]

Since we currently use Tomcat 6, which supports the servlet 2.5 specs (I 
think), we commented out the ASYNC dispatcher filter-mapping option.

--
Cris Berneburg
CACI Lead Software Engineer


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: OutOfMemoryError: PermGen space - SOLVED

2016-07-23 Thread Guido Jäkel
On 22.07.2016 19:15, Berneburg, Cris J. - US wrote:
> The OutOfMemoryError in Tomcat Manager was caused by a memory leak when Log4J 
> did not terminate properly.  This was due to my mistake of neglecting to set 
> up the necessary Log4J shutdown procedures.
> 
> Adding Log4jServletContextListener and log4jServletFilter to my app's web.xml 
> solved the problem.  The Find Leaks button on the Tomcat Manager page 
> confirmed.

Dear Chris,

may you add here a short snipped of your additions to the web.xml, please? As 
Mark said, this may also a good and convenient reference for others.


greetings

Guido


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: OutOfMemoryError: PermGen space - SOLVED

2016-07-22 Thread Mark Thomas
On 22/07/2016 19:15, Berneburg, Cris J. - US wrote:
> Mark (Thomas), Román, Guido, and Mark (Eggers)
> 
> Thank you all for your suggestions, assistance, and patience.
> 
> With your help and encouragement I learned how to perform heap dumps using 
> Java VisualVM, analyze them using Eclipse Memory Analyzer, and follow 
> instructions.  ;-)
> 
> The OutOfMemoryError in Tomcat Manager was caused by a memory leak when Log4J 
> did not terminate properly.  This was due to my mistake of neglecting to set 
> up the necessary Log4J shutdown procedures.
> 
> Adding Log4jServletContextListener and log4jServletFilter to my app's web.xml 
> solved the problem.  The Find Leaks button on the Tomcat Manager page 
> confirmed.
> 
> I apologize for taking your time and bandwidth on such a newbie mistake.

No need to apologize. Glad we were able to help. Tracking down memory
leaks is never easy and I would have said guiding someone how to do it
via e-mail is close to impossible. I'm impressed at how quickly you
managed to get this fixed.

As an added bonus we now have some great content in the archives to
point people to when they are trying to track down memory leaks.

> Thanks again for your help.  :-)

Not at all. Thanks for the good questions. A very large part of being
able to provide an helpful answer is a well written question.

Mark


> 
> --
> Cris Berneburg
> CACI Lead Software Engineer
> 
> -Original Message-
> From: Berneburg, Cris [mailto:cberneb...@caci.com] 
> Sent: Thursday, July 14, 2016 2:27 PM
> To: Tomcat Users List
> Subject: OutOfMemoryError: PermGen space
> 
>> Hi Folks
>>
>> I got this error from the Tomcat Web Application Manager after having
>> stopped and started one of the applications multiple times.  (This was
>> after repeatedly deploying the application manually to attempt to find
>> a bug that I could not reproduce in my IDE.)  Once the error occurred,
>> the server was extremely sluggish to respond even to remote desktop
>> mouse and keyboard events.
> 
> [SNIP]
> 
>> Here's the error:
>>
>> FAIL - Application at context path /someapp could not be started
>> FAIL - Encountered exception java.lang.OutOfMemoryError: PermGen space
>>
>> Is this likely due to a memory leak in my application?
> 
> [SNIP]
> 
>> OS: Win Server 2012 R2
>> Java: 1.6.0_24  (oops, need to upgrade that now)
>> Tomcat: 6.0.37  (hmm... will need to upgrade soon-ish)
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: OutOfMemoryError: PermGen space - SOLVED

2016-07-22 Thread Mark Eggers
Cris,

On 7/22/2016 10:15 AM, Berneburg, Cris J. - US wrote:
> Mark (Thomas), Román, Guido, and Mark (Eggers)
> 
> Thank you all for your suggestions, assistance, and patience.
> 
> With your help and encouragement I learned how to perform heap dumps
> using Java VisualVM, analyze them using Eclipse Memory Analyzer, and
> follow instructions.  ;-)
> 
> The OutOfMemoryError in Tomcat Manager was caused by a memory leak
> when Log4J did not terminate properly.  This was due to my mistake of
> neglecting to set up the necessary Log4J shutdown procedures.
> 
> Adding Log4jServletContextListener and log4jServletFilter to my app's
> web.xml solved the problem.  The Find Leaks button on the Tomcat
> Manager page confirmed.
> 
> I apologize for taking your time and bandwidth on such a newbie
> mistake.
> 
> Thanks again for your help.  :-)
> 
> -- Cris Berneburg CACI Lead Software Engineer
> 
> -Original Message- From: Berneburg, Cris
> [mailto:cberneb...@caci.com] Sent: Thursday, July 14, 2016 2:27 PM 
> To: Tomcat Users List Subject: OutOfMemoryError: PermGen space
> 
>> Hi Folks
>> 
>> I got this error from the Tomcat Web Application Manager after
>> having stopped and started one of the applications multiple times.
>> (This was after repeatedly deploying the application manually to
>> attempt to find a bug that I could not reproduce in my IDE.)  Once
>> the error occurred, the server was extremely sluggish to respond
>> even to remote desktop mouse and keyboard events.
> 
> [SNIP]
> 
>> Here's the error:
>> 
>> FAIL - Application at context path /someapp could not be started 
>> FAIL - Encountered exception java.lang.OutOfMemoryError: PermGen
>> space
>> 
>> Is this likely due to a memory leak in my application?
> 
> [SNIP]
> 
>> OS: Win Server 2012 R2 Java: 1.6.0_24  (oops, need to upgrade that
>> now) Tomcat: 6.0.37  (hmm... will need to upgrade soon-ish)

You're more than welcome. Glad that it was a simple 'read and follow the
instructions' problem. Been there, done that, have the palm prints on my
forehead.

Something I've made a habit of (after getting burned several times by
stray threads, threadlocals, and permgen errors) is to search for tomcat
/ servlet container in the context of using a library when I add a new
one to the mix.

That search has saved me lots of grief.

. . . just my two cents.
/mde/





signature.asc
Description: OpenPGP digital signature


RE: OutOfMemoryError: PermGen space - SOLVED

2016-07-22 Thread Berneburg, Cris J. - US
Mark (Thomas), Román, Guido, and Mark (Eggers)

Thank you all for your suggestions, assistance, and patience.

With your help and encouragement I learned how to perform heap dumps using Java 
VisualVM, analyze them using Eclipse Memory Analyzer, and follow instructions.  
;-)

The OutOfMemoryError in Tomcat Manager was caused by a memory leak when Log4J 
did not terminate properly.  This was due to my mistake of neglecting to set up 
the necessary Log4J shutdown procedures.

Adding Log4jServletContextListener and log4jServletFilter to my app's web.xml 
solved the problem.  The Find Leaks button on the Tomcat Manager page confirmed.

I apologize for taking your time and bandwidth on such a newbie mistake.

Thanks again for your help.  :-)

--
Cris Berneburg
CACI Lead Software Engineer

-Original Message-
From: Berneburg, Cris [mailto:cberneb...@caci.com] 
Sent: Thursday, July 14, 2016 2:27 PM
To: Tomcat Users List
Subject: OutOfMemoryError: PermGen space

> Hi Folks
>
> I got this error from the Tomcat Web Application Manager after having
> stopped and started one of the applications multiple times.  (This was
> after repeatedly deploying the application manually to attempt to find
> a bug that I could not reproduce in my IDE.)  Once the error occurred,
> the server was extremely sluggish to respond even to remote desktop
> mouse and keyboard events.

[SNIP]

> Here's the error:
>
> FAIL - Application at context path /someapp could not be started
> FAIL - Encountered exception java.lang.OutOfMemoryError: PermGen space
>
> Is this likely due to a memory leak in my application?

[SNIP]

> OS: Win Server 2012 R2
> Java: 1.6.0_24  (oops, need to upgrade that now)
> Tomcat: 6.0.37  (hmm... will need to upgrade soon-ish)


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org