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



RE: OutOfMemoryError: PermGen space

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

BLUF:  Memory leak found and fixed.  I did not set up the necessary Log4J 
shutdown procedures.  Please see below.

-Original Message-
From: Mark Eggers [mailto:its_toas...@yahoo.com.INVALID]
Sent: Thursday, July 21, 2016 8:32 PM
To: Tomcat Users List
Subject: Re: OutOfMemoryError: PermGen space

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

[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.
>
> *** I did not do that at all.  Is it the context listener's responsibility
> for shutting down properly?  Why the filter is needed?  Guess I'll set them
> up and see if that makes a diff.


That fixed it.  Adding Log4jServletContextListener and log4jServletFilter to my 
web.xml solves the problem.  The Find Leaks button on the Tomcat Manager page 
confirms.

Chalk it up to a newbie error.

Thanks for your help and patience.  :-)

--
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

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

BLUF:  I might not have set up the necessary Log4J shutdown procedures.  Please 
(especially) see my responses flagged by ***.

-Original Message-
From: Mark Eggers [mailto:its_toas...@yahoo.com.INVALID] 
Sent: Thursday, July 21, 2016 8:32 PM
To: Tomcat Users List
Subject: Re: OutOfMemoryError: PermGen space

> Mark and Cris,
> 
> On 7/21/2016 12:47 PM, Mark Thomas wrote:
> > On 21/07/2016 18:17, Berneburg, Cris wrote:
> >> From: Mark Thomas [mailto:ma...@apache.org]
> > 
> > 
> > 
> >> 
> >> Used the Java Visual VM to pull a heap dump after the app restart and 
> >> GC.  Used Eclipse Memory Analyzer to analyze the heap dumps.
> >> Found the WebappClassLoader with started == false and used Path to GC 
> >> roots:
> >> 
> >> 
> >> org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean ...
> >> com.sun.jmx.mbeanserver.StandardMBeanIntrospector
> >> 
> [SNIP]
> > 
> >> I don't see anything pointing back to our code.  With no previous 
> >> experience with heap analysis on my part, it looks to me to be due to 
> >> Log4J2.
> > 
> > Agreed.
> > 
> [SNIP]
> > 
> >> Not sure what else I can do.  Report it to the Log4J2 dev group 
> >> perhaps?
> > 
> > Ask on their users' list. It may be that when you use log4j2 in a 
> > webapp there is some clean-up method you need to call from a 
> > ServletContextListener.


OK, I'll follow up with that next-next.


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


Thanks for pointing that out.  I'm looking through it again now:


> 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. 


Hmm...  Log4j-web-2.3.jar is included in our apps lib folder.  I wonder if 
there is a shutdown procedure I am missing then.


> 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.


*** I did not do that at all.  Is it the context listener's responsibility for 
shutting down properly?  Why the filter is needed?  Guess I'll set them up and 
see if that makes a diff.


> Asynchronous Requests and Threads
> [SNIP]
> Note that you must call clearLoggerContext once your thread is
> finished processing. Failing to do so will result in memory leaks.


*** Wait a minute.  Maybe I don't understand how servlet threads work in 
Tomcat.  We don't launch any separate threads, but do override doPost and doGet 
in our servlets.  Is that synchronous or asynchronous?  Do we still have to 
call webLifeCycle.clearLoggerContext?


> In servlet spec 3.0 and greater, there appears to be annotation
> that gets everything running.
> 
> In servlet spec 2.5, you'll have to add a bunch of stuff to
> your web.xml.
>
> The reference above gives a more detailed explanation and an
> example for the 2.5 web.xml.


Since we still use Tomcat 6, we used a 2.5 servlet spec config.  All the Log4J 
config info is in log4j2.xml.


> I am just starting to get things migrated to log4j2,
> so I'll know how it goes shortly.


Please do!

--
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

2016-07-22 Thread Berneburg, Cris J. - US
Guido

Thanks for following up with me:

-Original Message-
From: Jäkel, Guido [mailto:g.jae...@dnb.de] 
Sent: Friday, July 22, 2016 4:31 AM
To: Berneburg, Cris
Subject: RE: OutOfMemoryError: PermGen space

> >-Original Message-
> >From: Berneburg, Cris [mailto:cberneb...@caci.com]
> >Sent: Thursday, July 21, 2016 6:18 PM
> >To: Tomcat Users List
> >Subject: RE: OutOfMemoryError: PermGen space
> >
> >Mark
> >
> >Thanks again for taking the time to assist with the OutOfMemoryError.  
> >BLUF, it looks like Log4J2 is the culprit.  Will you please check my work 
> >below to see if I have interpreted correctly?
> 
> Dear Chris,
> 
> Is the Log4J-JAR located at the "right place" with respect
> to the classloader path, i.e. inside the webapps lib directory?


Yup, the Log4J jars are in the webapp's lib folder and not in Tomcat's lib 
folder.  I just triple-checked.  ;-)


> Is Log4J2 is just used for your application or for Tomcat logging, too? 


Just for my app and not Tomcat.

--
Cris Berneburg
CACI Lead Software Engineer



RE: OutOfMemoryError: PermGen space

2016-07-22 Thread Berneburg, Cris J. - US
Mark

BLUF:  Thanks for your explanations and assistance.  I plan to follow up with 
the Log4J2 group.  My simple responses below.

-Original Message-
From: Mark Thomas [mailto:ma...@apache.org] 
Sent: Thursday, July 21, 2016 3:47 PM
To: Tomcat Users List
Subject: Re: OutOfMemoryError: PermGen space

> On 21/07/2016 18:17, Berneburg, Cris wrote:
> > From: Mark Thomas [mailto:ma...@apache.org]
> 
> 
> 
> > 
> > Used the Java Visual VM to pull a heap dump after the app
> > restart and GC.  Used Eclipse Memory Analyzer to analyze
> > the heap dumps.  Found the WebappClassLoader with started
> > == false and used Path to GC roots:
> > 
> >  org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean ... 
> > com.sun.jmx.mbeanserver.StandardMBeanIntrospector
> > 
> >  org.apache.logging.log4j.core.jmx.LoggerContextAdmin ... 
> > com.sun.jmx.mbeanserver.StandardMBeanIntrospector
> > 
> >  org.apache.logging.log4j.core.jmx.StatusLoggerAdmin ... 
> > com.sun.jmx.mbeanserver.StandardMBeanIntrospector
> 
> The three above look problematic.
> 
> > referent java.util.WeakHashMap$Entry ... java.lang.reflect.Proxy
> 
> That should disappear once the problematic entries have been fixed
> 
> >  $Proxy3 ... java.lang.reflect.Proxy
> 
> That looks to be related to the previous GC root and should also
> disappear once the problematic entries are fixed.
> 
> > referent java.util.WeakHashMap$Entry ... 
> > org.apache.juli.ClassLoaderLogManager
> > ... (many java.util.logging.*)
> 
> Again, those will disappear once the issues are fixed. They are Tomcat's
> internal logging


Thanks for explaining those to me.


> > I don't see anything pointing back to our code.  With 
> > no previous experience with heap analysis on my part,
> > it looks to me to be due to Log4J2.
> 
> Agreed.


Great!


> >  Changing the args for the call to LogManager.getLogger from
> Class clazz to none made no appreciable difference.
> 
> I wouldn't expect that to make any difference.
> 
> >  (Did I somehow set up Log4J2 incorrectly to get it to misbehave?)
> 
> I don't think so.


I wanted to make sure that holding onto class references wasn't a problem.  
Later I even replaced all the static vars with non-static locals as an 
experiment just in case ;-) and it made no diff.  Yeah, I know, you previously 
said that removing a static would not help, but I had to try anyway because I 
don't fully understand it all.  If there's a chance I did something goofy to 
cause the issue, I want to eliminate that possibility.


> >  Not sure what else I can do.  Report it to the Log4J2 dev group perhaps?
> 
> Ask on their users' list. It may be that when you use log4j2 in a webapp
> there is some clean-up method you need to call from a
> ServletContextListener.


OK, I'll do that next after following up with the other folks in this group.


> >> One thing worth noting. Yourkit offers two types of heap dumps.
> >> You don't want YourKit's own. There is a JVM bug that prevents
> >> some GC roots from being shown in that format and if your leak
> >> traces back to one of those you can end up scratching your head
> >> for days.
> >>
> >> Mark
> > 
> > 
> > Is there a likely chance that the bug interfered with my usage of
> > Java Visual VM and Eclipse Memory Analyzer and thus prevented me
> > from determining the real problem source?
> 
> No. The bug just hides GC roots. If the only GC roots you see are for
> weak references then you might have hit this bug.


Ah good, that's a relief and good to know.

Thanks!

--
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

2016-07-22 Thread Jäkel , Guido
>-Original Message-
>From: Berneburg, Cris J. - US [mailto:cberneb...@caci.com]
>Sent: Thursday, July 21, 2016 6:18 PM
>To: Tomcat Users List
>Subject: RE: OutOfMemoryError: PermGen space
>
>Mark
>
>Thanks again for taking the time to assist with the OutOfMemoryError.  BLUF, 
>it looks like Log4J2 is the culprit.  Will you
>please check my work below to see if I have interpreted correctly?

Dear Chris,

Is the Log4J-JAR located at the "right place" with respect to the classloader 
path, i.e. inside the webapps lib directory? Is Log4J2 is just used for your 
application or for Tomcat logging, too? 

Guido

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



Re: OutOfMemoryError: PermGen space

2016-07-21 Thread Mark Eggers
Mark and Cris,

On 7/21/2016 12:47 PM, Mark Thomas wrote:
> On 21/07/2016 18:17, Berneburg, Cris J. - US wrote:
>> From: Mark Thomas [mailto:ma...@apache.org]
> 
> 
> 
>> Using the Find Leaks button on the Tomcat Manager page on old app
>> versions to trigger full garbage collection revealed that the
>> memory leak started to happen in the release when Log4J2 was added
>> to the app.  It did not start happening in the prior release when
>> Mybatis was added.
> 
> It isn't essential but that is a good idea to do that to give you an 
> idea of what you are looking for.
> 
>>> This should help: http://markmail.org/message/fcbvwapt6afyndxn
>> 
>>> 1. Find an app that you can't reload without OOME 2. Get a
>>> profiler [...] 3. Reload you app once 4. Use the profiler to look
>>> for instances of WebappClassLoader 5. Look for the one with the
>>> started attribute == false 6. Trace the GC roots for this
>>> instance
>> 
>> 
>> Used the Java Visual VM to pull a heap dump after the app restart
>> and GC.  Used Eclipse Memory Analyzer to analyze the heap dumps.
>> Found the WebappClassLoader with started == false and used Path to
>> GC roots:
>> 
>> 
>> org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean ...
>> com.sun.jmx.mbeanserver.StandardMBeanIntrospector
>> 
>>  org.apache.logging.log4j.core.jmx.LoggerContextAdmin
>> ... com.sun.jmx.mbeanserver.StandardMBeanIntrospector
>> 
>>  org.apache.logging.log4j.core.jmx.StatusLoggerAdmin
>> ... com.sun.jmx.mbeanserver.StandardMBeanIntrospector
> 
> The three above look problematic.
> 
>> referent java.util.WeakHashMap$Entry ... java.lang.reflect.Proxy
> 
> That should disappear once the problematic entries have been fixed
> 
>>  $Proxy3 ... java.lang.reflect.Proxy
> 
> That looks to be related to the previous GC root and should also 
> disappear once the problematic entries are fixed.
> 
>> referent java.util.WeakHashMap$Entry ...
>> org.apache.juli.ClassLoaderLogManager ... (many
>> java.util.logging.*)
> 
> Again, those will disappear once the issues are fixed. They are
> Tomcat's internal logging
> 
>> I don't see anything pointing back to our code.  With no previous
>> experience with heap analysis on my part, it looks to me to be due
>> to Log4J2.
> 
> Agreed.
> 
>> Changing the args for the call to LogManager.getLogger from
>> Class clazz to none made no appreciable difference.
> 
> I wouldn't expect that to make any difference.
> 
>> (Did I somehow set up Log4J2 incorrectly to get it to misbehave?)
> 
> I don't think so.
> 
>> Not sure what else I can do.  Report it to the Log4J2 dev group
>> perhaps?
> 
> Ask on their users' list. It may be that when you use log4j2 in a
> webapp there is some clean-up method you need to call from a 
> ServletContextListener.
> 

From the log4j2 web site:

https://logging.apache.org/log4j/2.x/manual/webapp.html

In servlet spec 3.0 and greater, there appears to be annotation that
gets everything running.

In servlet spec 2.5, you'll have to add a bunch of stuff to your web.xml.

The reference above gives a more detailed explanation and an example for
the 2.5 web.xml.

I am just starting to get things migrated to log4j2, so I'll know how it
goes shortly.

Sigh . . . days late, and dollars short.

>>> One thing worth noting. Yourkit offers two types of heap dumps. 
>>> You don't want YourKit's own. There is a JVM bug that prevents 
>>> some GC roots from being shown in that format and if your leak 
>>> traces back to one of those you can end up scratching your head 
>>> for days.
>>> 
>>> Mark
>> 
>> 
>> Is there a likely chance that the bug interfered with my usage of
>> Java Visual VM and Eclipse Memory Analyzer and thus prevented me
>> from determining the real problem source?
> 
> No. The bug just hides GC roots. If the only GC roots you see are
> for weak references then you might have hit this bug.
> 
> Mark

. . . just my two cents
/mde/



signature.asc
Description: OpenPGP digital signature


Re: OutOfMemoryError: PermGen space

2016-07-21 Thread Mark Thomas
On 21/07/2016 18:17, Berneburg, Cris J. - US wrote:
> From: Mark Thomas [mailto:ma...@apache.org]



> Using the Find Leaks button on the Tomcat Manager page on old app versions to 
> trigger full garbage collection revealed that the memory leak started to 
> happen in the release when Log4J2 was added to the app.  It did not start 
> happening in the prior release when Mybatis was added.

It isn't essential but that is a good idea to do that to give you an
idea of what you are looking for.

>> This should help:
>> http://markmail.org/message/fcbvwapt6afyndxn
> 
>> 1. Find an app that you can't reload without OOME
>> 2. Get a profiler [...]
>> 3. Reload you app once
>> 4. Use the profiler to look for instances of WebappClassLoader
>> 5. Look for the one with the started attribute == false
>> 6. Trace the GC roots for this instance
> 
> 
> Used the Java Visual VM to pull a heap dump after the app restart and GC.  
> Used Eclipse Memory Analyzer to analyze the heap dumps.  Found the 
> WebappClassLoader with started == false and used Path to GC roots:
> 
>  org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean ... 
> com.sun.jmx.mbeanserver.StandardMBeanIntrospector
> 
>  org.apache.logging.log4j.core.jmx.LoggerContextAdmin ... 
> com.sun.jmx.mbeanserver.StandardMBeanIntrospector
> 
>  org.apache.logging.log4j.core.jmx.StatusLoggerAdmin ... 
> com.sun.jmx.mbeanserver.StandardMBeanIntrospector

The three above look problematic.

> referent java.util.WeakHashMap$Entry ... java.lang.reflect.Proxy

That should disappear once the problematic entries have been fixed

>  $Proxy3 ... java.lang.reflect.Proxy

That looks to be related to the previous GC root and should also
disappear once the problematic entries are fixed.

> referent java.util.WeakHashMap$Entry ... 
> org.apache.juli.ClassLoaderLogManager ... (many java.util.logging.*)

Again, those will disappear once the issues are fixed. They are Tomcat's
internal logging

> I don't see anything pointing back to our code.  With no previous experience 
> with heap analysis on my part, it looks to me to be due to Log4J2.

Agreed.

>  Changing the args for the call to LogManager.getLogger from Class clazz 
> to none made no appreciable difference.

I wouldn't expect that to make any difference.

>  (Did I somehow set up Log4J2 incorrectly to get it to misbehave?)

I don't think so.

>  Not sure what else I can do.  Report it to the Log4J2 dev group perhaps?

Ask on their users' list. It may be that when you use log4j2 in a webapp
there is some clean-up method you need to call from a
ServletContextListener.

>> One thing worth noting. Yourkit offers two types of heap dumps.
>> You don't want YourKit's own. There is a JVM bug that prevents
>> some GC roots from being shown in that format and if your leak
>> traces back to one of those you can end up scratching your head
>> for days.
>>
>> Mark
> 
> 
> Is there a likely chance that the bug interfered with my usage of Java Visual 
> VM and Eclipse Memory Analyzer and thus prevented me from determining the 
> real problem source?

No. The bug just hides GC roots. If the only GC roots you see are for
weak references then you might have hit this bug.

Mark


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



RE: OutOfMemoryError: PermGen space

2016-07-21 Thread Berneburg, Cris J. - US
Mark

Thanks again for taking the time to assist with the OutOfMemoryError.  BLUF, it 
looks like Log4J2 is the culprit.  Will you please check my work below to see 
if I have interpreted correctly?


-Original Message-
From: Mark Thomas [mailto:ma...@apache.org] 
Sent: Wednesday, July 20, 2016 12:17 PM
To: Tomcat Users List
Subject: Re: OutOfMemoryError: PermGen space

> On 20/07/2016 17:31, Berneburg, Cris wrote:
> > Mark
> > 
> > Thanks again for taking the time to educate me and answer my 
> > questions.  My lengthy replies below.  To summarize, our app does not 
> > seem to commit any egregious memory leak offenses, from what I can 
> > tell so far.  I plan to heap dump an older version of the app that 
> > does not use third-party libraries for comparison purposes.


Using the Find Leaks button on the Tomcat Manager page on old app versions to 
trigger full garbage collection revealed that the memory leak started to happen 
in the release when Log4J2 was added to the app.  It did not start happening in 
the prior release when Mybatis was added.


> This should help:
> http://markmail.org/message/fcbvwapt6afyndxn

> 1. Find an app that you can't reload without OOME
> 2. Get a profiler [...]
> 3. Reload you app once
> 4. Use the profiler to look for instances of WebappClassLoader
> 5. Look for the one with the started attribute == false
> 6. Trace the GC roots for this instance


Used the Java Visual VM to pull a heap dump after the app restart and GC.  Used 
Eclipse Memory Analyzer to analyze the heap dumps.  Found the WebappClassLoader 
with started == false and used Path to GC roots:

 org.apache.logging.log4j.core.jmx.LoggerContextAdminMBean ... 
com.sun.jmx.mbeanserver.StandardMBeanIntrospector

 org.apache.logging.log4j.core.jmx.LoggerContextAdmin ... 
com.sun.jmx.mbeanserver.StandardMBeanIntrospector

 org.apache.logging.log4j.core.jmx.StatusLoggerAdmin ... 
com.sun.jmx.mbeanserver.StandardMBeanIntrospector

referent java.util.WeakHashMap$Entry ... java.lang.reflect.Proxy

 $Proxy3 ... java.lang.reflect.Proxy

referent java.util.WeakHashMap$Entry ... org.apache.juli.ClassLoaderLogManager 
... (many java.util.logging.*)

I don't see anything pointing back to our code.  With no previous experience 
with heap analysis on my part, it looks to me to be due to Log4J2.  Changing 
the args for the call to LogManager.getLogger from Class clazz to none made 
no appreciable difference.  (Did I somehow set up Log4J2 incorrectly to get it 
to misbehave?)  Not sure what else I can do.  Report it to the Log4J2 dev group 
perhaps?


> One thing worth noting. Yourkit offers two types of heap dumps.
> You don't want YourKit's own. There is a JVM bug that prevents
> some GC roots from being shown in that format and if your leak
> traces back to one of those you can end up scratching your head
> for days.
> 
> Mark


Is there a likely chance that the bug interfered with my usage of Java Visual 
VM and Eclipse Memory Analyzer and thus prevented me from determining the real 
problem source?

--
Cris Berneburg, Lead Software Engineer, CACI


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



Re: OutOfMemoryError: PermGen space

2016-07-20 Thread Mark Thomas
On 20/07/2016 17:31, Berneburg, Cris J. - US wrote:
> Mark
> 
> Thanks again for taking the time to educate me and answer my
> questions.  My lengthy replies below.  To summarize, our app does not
> seem to commit any egregious memory leak offenses, from what I can
> tell so far.  I plan to heap dump an older version of the app that
> does not use third-party libraries for comparison purposes.

This should help:
http://markmail.org/message/fcbvwapt6afyndxn

One thing worth noting. Yourkit offers two types of heap dumps. You
don't want YourKit's own. There is a JVM bug that prevents some GC roots
from being shown in that format and if your leak traces back to one of
those you can end up scratching your head for days.

Mark

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



RE: OutOfMemoryError: PermGen space

2016-07-20 Thread Berneburg, Cris J. - US
Mark

Thanks again for taking the time to educate me and answer my questions.  My 
lengthy replies below.  To summarize, our app does not seem to commit any 
egregious memory leak offenses, from what I can tell so far.  I plan to heap 
dump an older version of the app that does not use third-party libraries for 
comparison purposes.


-Original Message-
From: Mark Thomas [mailto:ma...@apache.org] 
Sent: Tuesday, July 19, 2016 3:15 PM
To: Tomcat Users List
Subject: Re: OutOfMemoryError: PermGen space

> On 19/07/2016 17:19, Berneburg, Cris J. - US wrote:
> 
> 
> 
> >> This is probably a useful read:
> >> http://people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks
> >> -60mins.pdf
> >>
> >> Despite the age, it is still very relevant today.
> > 
> > 
> > Thanks for reminding me about that document.  It does sound relevant.  
> > The document says,
> > 
> >> How memory leaks occur: Reference chains [...] Retaining a reference 
> >> to a single object from a web application pins every class loaded by 
> >> the web application in the Permanent Generation
> > 
> > Practically speaking, how is a reference retained?
> > 1. Is a module-level (member) variable in a Servlet an example?
> 
> No. Assuming the class that defines the Servlet is packaged with the
> web application (i.e. in a JAR in WEB-INF/lib or in WEB-INF/classes


All our servlets are classes in WEB-INF/classes.


> > 2. How about using ServletContext.setAttribute without an accompanying
> > removeAttribute?
> 
> No.
> 
> > 3. I see in one of my listeners some member (module-level) variables:
> > a private static for the logger and also a protected final String.
> > Is that a problem?
> 
> No.


Dang, I was hoping that would be it.  :-)


> > If you could provide a little more guidance about the details, I would
> > appreciate it.
> 
> Sure.
> 
> There are two categories of objects we are concerned about. Objects
> defined by classes that are provided by your web application (in
> WEB-INF/lib or WEB-INF/classes) and objects defined by classes that
> are provided by the container (Tomcat) or the JVM.
> 
> References from web application objects to web application objects
> are fine.
> 
> References from web application objects to container objects are fine.
> 
> References from container objects to web application objects are
> potentially a problem.
> 
> Additionally, references from container objects to the web application
> class loader are potentially a problem.


Hmm... I'm gonna need some time to absorb that.


> For example:
> 
> When you start a thread in a web application, the thread context
> class loader will be the web application class loader and the thread
> holds a reference to this. If the thread is not stopped when the web
> application is stopped there will be a reference held to the web
> application class loader which will cause a leak.


To my knowledge we are not explicitly starting any new threads.  Our app is 
pretty basic.


> If you add a logging framework to Tomcat's lib directory and then
> package a custom log formatter with your web application, the formatter
> will be registered with the logging framework and unless you unregister
> it when the application stops there will be reference from logging
> framework to custom formatter object to custom formatter class to web
> application class loader which will cause a leak.


We did not program a custom formatter with LOG4J2, just used a format parm in 
the config.  Also, LOG4J jar files were added the to the app WEB-INF/lib 
folder, not Tomcat's.

Sounds like there are a lot of potential sources for memory leaks.  I'm either 
going to have to keep digging deeper using a heap dump tool or simply punt 
without figuring it out.  Will a heap dump analyzer reveal what instances are 
in PermGen space and what has references to them?  Maybe I can follow up a 
chain of references to determine the source.

In the heap dump the largest collection of instances is java.lang.String.  
Could concatenation by assignment be a problem?  Example, abc = abc + xzy.  
While we are guilty of that, performing a heap dump on a fresh, idle, unused 
app would not have called the offending code.  So that cannot be it.

The second and third largest groups of instances in the heap dump are char[] 
and java.util.HashMap$Entry.  They must be from a library or third-party class, 
since not one char or HashMap instance is declared in our entire application.

As an experiment, I may grab heap dumps from and restart an older version of 
the app that does not use Mybatis or Log4J to see how that affects the top 3 
class instances.  If the sizes are significantly smaller, then perhaps th

RE: OutOfMemoryError: PermGen space

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

Thanks for taking the time to answer my questions and make suggestions.  My 
replies below.


-Original Message-
From: Jäkel, Guido [mailto:g.jae...@dnb.de] 
Sent: Tuesday, July 19, 2016 10:31 AM
To: 'Tomcat Users List'
Subject: RE: OutOfMemoryError: PermGen space

>> In Visual VM, under File, Compare Memory Snapshots, it does not see the 
>> snapshots I generated.  The snapshots appear to be extension *.apps, 
>> but the compare function looks for files with extension *.nps.  I don't
>> know how to get the compare function to work.
>> 
>> Not sure where to go from here.  Got any suggestions?
> 
> You may pull heap dumps and use the Eclipse Memory Analyzer Toolkit (aka
> MAT)  (http://www.eclipse.org/mat/) to discover stale objects danging on
> the webapps classloader. The tool may be used stand-alone (via an included
> Eclipse RCP) or as an Eclipse Plugin.


Thanks for the suggestion.  I've never used that tool before.  Will it read the 
heap dumps generated by Visual VM?  I'll either try MAT or see if IntelliJ Idea 
has one, since Idea is my IDE.


[SNIP]

> If possible in any way, please upgrade to (Oracle) Java 1.8, because to
> my experience, there seems even notable fixes inside the Java core
> libraries. And enable the newest "G1" garabarge collector, too. Without
> changing any line in our apps, the JVM heap usage was notable smaller
> and smoother. Because of migrating with the [...] VM, the PermGen-Heap
> have been replaced by the Metaspace-Heap. Some parts of allocation now
> in the main heap and is reclaimable, some other remain. But technical,
> the Metaspace heap is now handled as all others, therefore it has no
> real separate size. You may set (and should) a limit, but per default
> it's unlimitied within the main heap.


I plan on upgrading to Java 1.8 soon but not quite yet, hoping to figure this 
out before doing so.  I don't want to change something that could potentially 
make the symptom go away but simply hide the underlying problem.

Thanks for reminding me about G1.  Is there any reason not to enable G1 garbage 
collection?  Also, Google says that there are potentially 3 ways of enabling it:

1. Customizing the Tomcat startup procedures to add the -XX:+UseG1GC option.  
This requires modifying the Tomcat startup every time you install Tomcat.

2. Setting the JAVA_TOOL_OPTIONS Java environment variable.  This makes G1 
default for all Java applications.

3. Setting the JAVA_OPTS environment variable that Tomcat might look for?  Not 
sure about this one.


> Greetings
> 
> Guido

--
Cris Berneburg, Lead Software Engineer, CACI



Re: OutOfMemoryError: PermGen space

2016-07-19 Thread Román Valoria
Cris:

You are looking at the wrong memory object. You need to focus on the
PermGen memory tab, not the Heap one.

That is, of course, if your memory error is indeed mentioning PermGen as in
the subject of this mail.

Again the PermGen holds the classes metadata definitions, so it should not
be impacted by how many times you call the classes or how much memory they
consume or how much data you are loading into memory.

I have never ran it with anything later than Java 6 and Tomcat 7, so I
cannot comment you your other errors.

Regards,

Roman.

On Tue, Jul 19, 2016 at 10:08 PM, Berneburg, Cris J. - US <
cberneb...@caci.com> wrote:

> Román
>
> Thanks for taking the time to reply and educate me.  :-)  Please see my
> ramblings below.
>
> -Original Message-
> From: Román Valoria [mailto:romanvalo...@gmail.com]
> Sent: Thursday, July 14, 2016 11:28 PM
> To: Tomcat Users List
> Subject: Re: OutOfMemoryError: PermGen space
>
> > Cris:
> >
> > Couple of things here.
> >
> > First, you can use in any Java 6 Update 45 and above the Java Visual VM,
> > to monitor in real time the memory utilization done by the Java virtual
> > machine. This will show you both the Help and Perm Gen memory graphs.
> > You can find this tool in the bin directory of any JDK.
>
>
> Thanks for suggesting that.  I have never used the Java Visual VM before.
> Upon trying it, I can't seem to get the tool to find Tomcat running, even
> when starting the tool with administrative privileges.  The only local
> application it sees is itself, VisualVM.  Tomcat is not visible to the tool
> running either as a Windows service nor by starting using startup.bat.
>
> Having never used the tool before I suspect I have missed something very
> basic.  Hmm... Google says I need to enable JMX on Tomcat and then add the
> JMX connection to Visual VM.  No dice, still can't see Tomcat.  Java bug
> #7009828 (http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7009828)
> prevents Visual VM from connecting but says I can launch the tool with
> Java's temp directory matching Tomcat's temp dir (or something like that).
> That did it!  Now Visual VM can see Tomcat.
>
> I took a snapshot and heap dump, restarted my app 5x, then took another
> snapshot and heap dump.  The first dump is 25MB, and the second after all
> the restarts is 46MB.  The top 3 classes in both are java.lang.String,
> char[], java.util.HashMap$Entry.  How do I pinpoint where a potential
> problem is?
>
> In Visual VM, under File, Compare Memory Snapshots, it does not see the
> snapshots I generated.  The snapshots appear to be extension *.apps, but
> the compare function looks for files with extension *.nps.  I don't know
> how to get the compare function to work.
>
> Not sure where to go from here.  Got any suggestions?
>
>
> > Second, you can issue some Java parameters to actually enlarge the
> > PermGen memory allocation upon startup. Please refer to your java
> > version documentation on Oracle and lookup for the -XX parameters.
> >
> > You can start by enlarging your PermGen space and the monitor on the
> > Visual VM the behavior, if you consistently run out of memory, then
> > you may have a leak.
> >
> > Of course that you would be constrained by the fact of running a
> > 32-bit or 64-bit Tomcat / Java environment.
> >
> >
> > On Fri, Jul 15, 2016 at 2:26 AM, Berneburg, Cris J. - US <
> cberneb...@caci.com> wrote:
> >
> > > 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.
> > >
> > > FYI, I deploy the app by stopping it on the Tomcat web manager,
> > > deleting almost everything out of the app folder using file manager,
> > > copying the new files and folders in, then starting the app from the
> Tomcat manager.
> > >
> > > 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?  Or does it
> > > have something to do with me doing so many repeated deployments?  Or
> > > perhaps simply from restarting the app so many times?  I might try an
> > > experiment to see how many times I can stop/start the app before the
> error next occurs.
> > >
> > > 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)
> > >
> > > --
> > > Cris Berneburg, Lead Software Engineer, CACI
> > >
>
> --
> Cris Berneburg, Lead Software Engineer, CACI
>
>


Re: OutOfMemoryError: PermGen space

2016-07-19 Thread Mark Thomas
On 19/07/2016 17:19, Berneburg, Cris J. - US wrote:



>> This is probably a useful read:
>> http://people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks-60mins.pdf
>>
>> Despite the age, it is still very relevant today.
> 
> 
> Thanks for reminding me about that document.  It does sound relevant.  The 
> document says,
> 
>> How memory leaks occur: Reference chains
>> [...]
>> Retaining a reference to a single object from a web application
>> pins every class loaded by the web application in the Permanent
>> Generation
> 
> Practically speaking, how is a reference retained?
> 1. Is a module-level (member) variable in a Servlet an example?

No. Assuming the class that defines the Servlet is packaged with the web
application (i.e. in a JAR in WEB-INF/lib or in WEB-INF/classes

> 2. How about using ServletContext.setAttribute without an accompanying 
> removeAttribute?

No.

> 3. I see in one of my listeners some member (module-level) variables: a 
> private static for the logger and also a protected final String.  Is that a 
> problem?

No.

> If you could provide a little more guidance about the details, I would 
> appreciate it.

Sure.

There are two categories of objects we are concerned about. Objects
defined by classes that are provided by your web application (in
WEB-INF/lib or WEB-INF/classes) and objects defined by classes that are
provided by the container (Tomcat) or the JVM.

References from web application objects to web application objects are fine.

References from web application objects to container objects are fine.

References from container objects to web application objects are
potentially a problem.

Additionally, references from container objects to the web application
class loader are potentially a problem.

For example:

When you start a thread in a web application, the thread context class
loader will be the web application class loader and the thread holds a
reference to this. If the thread is not stopped when the web application
is stopped there will be a reference held to the web application class
loader which will cause a leak.

If you add a logging framework to Tomcat's lib directory and then
package a custom log formatter with your web application, the formatter
will be registered with the logging framework and unless you unregister
it when the application stops there will be reference from logging
framework to custom formatter object to custom formatter class to web
application class loader which will cause a leak.

HTH,

Mark

P.S. I'll be talking about this (hopefully - if my talk gets accepted)
at ApacheCon EU later this year.


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



RE: OutOfMemoryError: PermGen space

2016-07-19 Thread Berneburg, Cris J. - US
Mark

Thanks for taking the time to answer my questions.  Please see my response and 
questions below.

-Original Message-
From: Mark Thomas [mailto:ma...@apache.org] 
Sent: Thursday, July 14, 2016 2:58 PM
To: Tomcat Users List
Subject: Re: OutOfMemoryError: PermGen space

> On 14/07/2016 20:26, Berneburg, Cris wrote:
> 
> > 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?
> 
> Yes.
> 
> >  Or does it have something to do with me doing so many repeated deployments?
> 
> Also yes.
> 
> >  Or perhaps simply from restarting the app so many times?
> 
> Stop/start has the same effect as redeploy in this case.
> 
> >  I might try an experiment to see how many times I can stop/start the
> > app before the error next occurs.
> > 
> > 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)
> 
> Indeed. Some upgrades are certainly in order. Not least because some of
> the potential sources of memory leaks are JVM bugs that are fixed in
> the lastest Java 8 releases.
> 
> This is probably a useful read:
> http://people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks-60mins.pdf
> 
> Despite the age, it is still very relevant today.


Thanks for reminding me about that document.  It does sound relevant.  The 
document says,

> How memory leaks occur: Reference chains
> [...]
> Retaining a reference to a single object from a web application
> pins every class loaded by the web application in the Permanent
> Generation

Practically speaking, how is a reference retained?
1. Is a module-level (member) variable in a Servlet an example?
2. How about using ServletContext.setAttribute without an accompanying 
removeAttribute?
3. I see in one of my listeners some member (module-level) variables: a private 
static for the logger and also a protected final String.  Is that a problem?

If you could provide a little more guidance about the details, I would 
appreciate it.

> Mark

--
Cris Berneburg, Lead Software Engineer, CACI


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



RE: OutOfMemoryError: PermGen space

2016-07-19 Thread Jäkel , Guido
>In Visual VM, under File, Compare Memory Snapshots, it does not see the 
>snapshots I generated.  The snapshots appear to
>be extension *.apps, but the compare function looks for files with extension 
>*.nps.  I don't know how to get the compare
>function to work.
>
>Not sure where to go from here.  Got any suggestions?

You may pull heap dumps and use the Eclipse Memory Analyzer Toolkit (aka MAT)  
(http://www.eclipse.org/mat/) to discover stale objects danging on the webapps 
classloader. The tool may be used stand-alone (via an included  Eclipse RCP) or 
as an Eclipse Plugin.


Greetings

Guido


RE: OutOfMemoryError: PermGen space

2016-07-19 Thread Berneburg, Cris J. - US
Román

Thanks for taking the time to reply and educate me.  :-)  Please see my 
ramblings below.

-Original Message-
From: Román Valoria [mailto:romanvalo...@gmail.com] 
Sent: Thursday, July 14, 2016 11:28 PM
To: Tomcat Users List
Subject: Re: OutOfMemoryError: PermGen space

> Cris:
> 
> Couple of things here.
> 
> First, you can use in any Java 6 Update 45 and above the Java Visual VM,
> to monitor in real time the memory utilization done by the Java virtual
> machine. This will show you both the Help and Perm Gen memory graphs.
> You can find this tool in the bin directory of any JDK.


Thanks for suggesting that.  I have never used the Java Visual VM before.  Upon 
trying it, I can't seem to get the tool to find Tomcat running, even when 
starting the tool with administrative privileges.  The only local application 
it sees is itself, VisualVM.  Tomcat is not visible to the tool running either 
as a Windows service nor by starting using startup.bat.

Having never used the tool before I suspect I have missed something very basic. 
 Hmm... Google says I need to enable JMX on Tomcat and then add the JMX 
connection to Visual VM.  No dice, still can't see Tomcat.  Java bug #7009828 
(http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7009828) prevents Visual 
VM from connecting but says I can launch the tool with Java's temp directory 
matching Tomcat's temp dir (or something like that).  That did it!  Now Visual 
VM can see Tomcat.

I took a snapshot and heap dump, restarted my app 5x, then took another 
snapshot and heap dump.  The first dump is 25MB, and the second after all the 
restarts is 46MB.  The top 3 classes in both are java.lang.String, char[], 
java.util.HashMap$Entry.  How do I pinpoint where a potential problem is?

In Visual VM, under File, Compare Memory Snapshots, it does not see the 
snapshots I generated.  The snapshots appear to be extension *.apps, but the 
compare function looks for files with extension *.nps.  I don't know how to get 
the compare function to work.

Not sure where to go from here.  Got any suggestions?


> Second, you can issue some Java parameters to actually enlarge the
> PermGen memory allocation upon startup. Please refer to your java
> version documentation on Oracle and lookup for the -XX parameters.
> 
> You can start by enlarging your PermGen space and the monitor on the
> Visual VM the behavior, if you consistently run out of memory, then
> you may have a leak.
>
> Of course that you would be constrained by the fact of running a
> 32-bit or 64-bit Tomcat / Java environment.
> 
> 
> On Fri, Jul 15, 2016 at 2:26 AM, Berneburg, Cris J. - US < 
> cberneb...@caci.com> wrote:
> 
> > 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.
> >
> > FYI, I deploy the app by stopping it on the Tomcat web manager, 
> > deleting almost everything out of the app folder using file manager, 
> > copying the new files and folders in, then starting the app from the Tomcat 
> > manager.
> >
> > 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?  Or does it 
> > have something to do with me doing so many repeated deployments?  Or 
> > perhaps simply from restarting the app so many times?  I might try an 
> > experiment to see how many times I can stop/start the app before the error 
> > next occurs.
> >
> > 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)
> >
> > --
> > Cris Berneburg, Lead Software Engineer, CACI
> >

--
Cris Berneburg, Lead Software Engineer, CACI



Re: OutOfMemoryError: PermGen space

2016-07-14 Thread Román Valoria
Cris:

Couple of things here.

First, you can use in any Java 6 Update 45 and above the Java Visual VM, to
monitor in real time the memory utilization done by the Java virtual
machine. This will show you both the Help and Perm Gen memory graphs. You
can find this tool in the bin directory of any JDK.

Second, you can issue some Java parameters to actually enlarge the PermGen
memory allocation upon startup. Please refer to your java version
documentation on Oracle and lookup for the -XX parameters.

You can start by enlarging your PermGen space and the monitor on the Visual
VM the behavior, if you consistently run out of memory, then you may have a
leak.

Of course that you would be constrained by the fact of running a 32-bit or
64-bit Tomcat / Java environment.


On Fri, Jul 15, 2016 at 2:26 AM, Berneburg, Cris J. - US <
cberneb...@caci.com> wrote:

> 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.
>
> FYI, I deploy the app by stopping it on the Tomcat web manager, deleting
> almost everything out of the app folder using file manager, copying the new
> files and folders in, then starting the app from the Tomcat manager.
>
> 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?  Or does it have
> something to do with me doing so many repeated deployments?  Or perhaps
> simply from restarting the app so many times?  I might try an experiment to
> see how many times I can stop/start the app before the error next occurs.
>
> 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)
>
> --
> Cris Berneburg, Lead Software Engineer, CACI
>
>


Re: OutOfMemoryError: PermGen space

2016-07-14 Thread Mark Thomas
On 14/07/2016 20:26, Berneburg, Cris J. - US wrote:
> 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.
> 
> FYI, I deploy the app by stopping it on the Tomcat web manager, deleting 
> almost everything out of the app folder using file manager, copying the new 
> files and folders in, then starting the app from the Tomcat manager.
> 
> 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?

Yes.

>  Or does it have something to do with me doing so many repeated deployments?

Also yes.

>  Or perhaps simply from restarting the app so many times?

Stop/start has the same effect as redeploy in this case.

>  I might try an experiment to see how many times I can stop/start the app 
> before the error next occurs.
> 
> 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)

Indeed. Some upgrades are certainly in order. Not least because some of
the potential sources of memory leaks are JVM bugs that are fixed in the
lastest Java 8 releases.

This is probably a useful read:
http://people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks-60mins.pdf

Despite the age, it is still very relevant today.

Mark


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



OutOfMemoryError: PermGen space

2016-07-14 Thread Berneburg, Cris J. - US
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.

FYI, I deploy the app by stopping it on the Tomcat web manager, deleting almost 
everything out of the app folder using file manager, copying the new files and 
folders in, then starting the app from the Tomcat manager.

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?  Or does it have 
something to do with me doing so many repeated deployments?  Or perhaps simply 
from restarting the app so many times?  I might try an experiment to see how 
many times I can stop/start the app before the error next occurs.

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)

--
Cris Berneburg, Lead Software Engineer, CACI



Re: OutOfMemoryError: PermGen space!!!! Dont know why?

2010-09-16 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

abhi,

On 9/16/2010 3:21 AM, abhishek jain wrote:
> hi
> ps axf --cols 1000 | grep java returns
> 
> 29807 pts/2S+ 0:00  \_ grep java
> 19511 ?Ss 0:00 jsvc.exec -user tomcat -cp ./bootstrap.jar
> -Djava.endorsed.dirs=../common/endorsed -outfile ../logs/catalina.out
> -errfile ../logs/catalina.err -verbose org.apache.catalina.startup.Bootstrap
> -security
> 19512 ?Sl11:57  \_ jsvc.exec -user tomcat -cp ./bootstrap.jar
> -Djava.endorsed.dirs=../common/endorsed -outfile ../logs/catalina.out
> -errfile ../logs/catalina.err -verbose org.apache.catalina.startup.Bootstrap
> -security
> 
> and echo $JAVA_OPTS
> 
> returns a blank line
> Pl advice what should i do,

Try these:

$ jps
(sample output)
13747 Bootstrap
3254 Bootstrap
31762 Bootstrap
32352 Jps

Then, choose which one you want to inspect and do:

$ jinfo 13747
Attaching to process ID 13747, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 16.3-b01
Java System Properties:

java.runtime.name = Java(TM) SE Runtime Environment
sun.boot.library.path = /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/i386
java.vm.version = 16.3-b01
shared.loader =
java.vm.vendor = Sun Microsystems Inc.
java.vendor.url = http://java.sun.com/
path.separator = :
tomcat.util.buf.StringCache.byte.enabled = true
java.vm.name = Java HotSpot(TM) Server VM
file.encoding.pkg = sun.io
sun.java.launcher = SUN_STANDARD
user.country = US
sun.os.patch.level = unknown
java.vm.specification.name = Java Virtual Machine Specification
user.dir = /...
java.runtime.version = 1.6.0_20-b02
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.endorsed.dirs = /usr/local/apache-tomcat-6.0.26/endorsed
os.arch = i386
java.io.tmpdir = /...
line.separator =

java.vm.specification.vendor = Sun Microsystems Inc.
java.naming.factory.url.pkgs = org.apache.naming
java.util.logging.manager = org.apache.juli.ClassLoaderLogManager
os.name = Linux
sun.jnu.encoding = UTF-8
java.library.path = /usr/local/apache-tomcat-6.0.26/server/lib
java.specification.name = Java Platform API Specification
java.class.version = 50.0
org.apache.catalina.STRICT_SERVLET_COMPLIANCE = true
sun.management.compiler = HotSpot Tiered Compilers
os.version = 2.6.18-14-fza-686-bigmem
user.home = /home/cschultz
catalina.useNaming = true
user.timezone = America/New_York
java.awt.printerjob = sun.print.PSPrinterJob
file.encoding = UTF-8
java.specification.version = 1.6
catalina.home = /usr/local/apache-tomcat-6.0.26
java.class.path = /usr/local/apache-tomcat-6.0.26/bin/bootstrap.jar
user.name = cschultz
java.naming.factory.initial = org.apache.naming.java.javaURLContextFactory
package.definition =
sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.
java.vm.specification.version = 1.0
java.home = /usr/lib/jvm/java-6-sun-1.6.0.20/jre
sun.arch.data.model = 32
user.language = en
java.specification.vendor = Sun Microsystems Inc.
java.vm.info = mixed mode
java.version = 1.6.0_20
java.ext.dirs =
/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path =
/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/resources.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/jce.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/classes
server.loader =
java.vendor = Sun Microsystems Inc.
catalina.base = /...
nop =
file.separator = /
java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi
common.loader = ${catalina.home}/lib,${catalina.home}/lib/*.jar
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
package.access =
sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans.
sun.cpu.isalist =

VM Flags:

- -Dnop -Xmx64M
- -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
- -Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=true
- -Djava.library.path=/usr/local/apache-tomcat-6.0.26/server/lib
- -Djava.endorsed.dirs=/usr/local/apache-tomcat-6.0.26/endorsed
- -Dcatalina.base=/... -Dcatalina.home=/usr/local/apache-tomcat-6.0.26
- -Djava.io.tmpdir=/...


And try this one:

$ jmap -heap 13747
Attaching to process ID 13747, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 16.3-b01

using thread-local object allocation.
Parallel GC with 4 thread(s)

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize  = 67108864 (64.0MB)
   NewSize  = 4194304 (4.0MB)
   MaxNewSize   = 4294901760 (4095.9375MB)
   OldSize  = 4194304 (4.0MB)
   NewRatio = 2
   SurvivorRatio= 8
   PermSize = 16777216 (16.0MB)
   MaxPermSize  = 67108864 (64.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 1900544 (1.8125MB)
   used = 384

Re: OutOfMemoryError: PermGen space!!!! Dont know why?

2010-09-16 Thread André Warnier

abhishek jain wrote:

hi
ps axf --cols 1000 | grep java returns

29807 pts/2S+ 0:00  \_ grep java
19511 ?Ss 0:00 jsvc.exec -user tomcat -cp ./bootstrap.jar
-Djava.endorsed.dirs=../common/endorsed -outfile ../logs/catalina.out
-errfile ../logs/catalina.err -verbose org.apache.catalina.startup.Bootstrap
-security
19512 ?Sl11:57  \_ jsvc.exec -user tomcat -cp ./bootstrap.jar
-Djava.endorsed.dirs=../common/endorsed -outfile ../logs/catalina.out
-errfile ../logs/catalina.err -verbose org.apache.catalina.startup.Bootstrap
-security

and echo $JAVA_OPTS

returns a blank line
Pl advice what should i do,


Obviously on your system (a Linux or Unix -like system), Tomcat is being started using 
jsvc as a "wrapper" for the java JVM.


"jsvc" is not a part of Tomcat. If your system uses it to start Tomcat, it is because the 
creators of the Tomcat package for your platform have decided to use it.


You should probably start by reading the jsvc documentation, at :
http://commons.apache.org/daemon/
Read the introduction on this page, and then follow the link to jsvc.
This will really clear things up, and will tell you also how to provide start-up 
parameters to jsvc, so that it starts java in the way you want, with the options you want.


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



Re: OutOfMemoryError: PermGen space!!!! Dont know why?

2010-09-16 Thread abhishek jain
hi
ps axf --cols 1000 | grep java returns

29807 pts/2S+ 0:00  \_ grep java
19511 ?Ss 0:00 jsvc.exec -user tomcat -cp ./bootstrap.jar
-Djava.endorsed.dirs=../common/endorsed -outfile ../logs/catalina.out
-errfile ../logs/catalina.err -verbose org.apache.catalina.startup.Bootstrap
-security
19512 ?Sl11:57  \_ jsvc.exec -user tomcat -cp ./bootstrap.jar
-Djava.endorsed.dirs=../common/endorsed -outfile ../logs/catalina.out
-errfile ../logs/catalina.err -verbose org.apache.catalina.startup.Bootstrap
-security

and echo $JAVA_OPTS

returns a blank line
Pl advice what should i do,
thanks
abhi


On Wed, Sep 15, 2010 at 6:06 PM, Peter McNeil  wrote:

> Check the process for java has the correct max perm size set. If you're
> using linux do a
>
> ps axf --cols 1000 | grep java
>
> A max PermSize of 1024m is pretty big...
> My tomcat 6 instance running several apps returns:-
>
>  /usr/java/latest/bin/java
> -Djava.util.logging.config.file=/home/pmcneil/apps/tomcat/apache-tomcat-6.0.24/conf/logging.properties
> -server -Xmx2000m -XX:MaxPermSize=400m
> -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
> -Djava.endorsed.dirs=/home/pmcneil/apps/tomcat/apache-tomcat-6.0.24/endorsed
> -classpath /home/pmcneil/apps/tomcat/apache-tomcat-6.0.24/bin/bootstrap.jar
> -Dcatalina.base=/home/pmcneil/apps/tomcat/apache-tomcat-6.0.24
> -Dcatalina.home=/home/pmcneil/apps/tomcat/apache-tomcat-6.0.24
> -Djava.io.tmpdir=/home/pmcneil/apps/tomcat/apache-tomcat-6.0.24/temp
> org.apache.catalina.startup.Bootstrap start
>
> and my JAVA_OPTS is ...
> echo $JAVA_OPTS
> -server -Xmx2000m -XX:MaxPermSize=400m
>
> If that all looks OK you have a memory leak, try using jconsole and look at
> threads and deadlocks etc.
>
> Good luck,
> Peter.
>
>
> On 15/09/10 16:28, abhishek jain wrote:
>
>> Hi,
>> i have the following in bin/catalina.sh
>>
>>   JAVA_OPTS="$JAVA_OPTS -server -Xms512M -Xmx1024M -XX:MaxPermSize=1024M
>> -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
>>
>> still i get the permgen error exception everyday, pl. someone help, i have
>> about 7 applications in struts running on the server, the applications are
>> in struts 1.2 , mysql, tomcat 5.5, and are not big applications with about
>> only a few jsps.
>>
>> I consider the applications written properly, pl. help,
>>
>>
>>
>
>


Re: OutOfMemoryError: PermGen space!!!! Dont know why?

2010-09-15 Thread Pid
On 15/09/2010 07:28, abhishek jain wrote:
> Hi,
> i have the following in bin/catalina.sh
> 
>   JAVA_OPTS="$JAVA_OPTS -server -Xms512M -Xmx1024M -XX:MaxPermSize=1024M
> -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
> 
> still i get the permgen error exception everyday, pl. someone help, i have
> about 7 applications in struts running on the server, the applications are
> in struts 1.2 , mysql, tomcat 5.5, and are not big applications with about
> only a few jsps.

Tomcat 5.5.what?

> I consider the applications written properly, pl. help,

When did this problem start?

Have you actually got enough free memory available?

Are you reloading the application, or updating JSPs regularly?


p


0x62590808.asc
Description: application/pgp-keys


signature.asc
Description: OpenPGP digital signature


Re: OutOfMemoryError: PermGen space!!!! Dont know why?

2010-09-15 Thread Edmund Urbani
 On 09/15/10 08:28, abhishek jain wrote:
> Hi,
> i have the following in bin/catalina.sh
>
>   JAVA_OPTS="$JAVA_OPTS -server -Xms512M -Xmx1024M -XX:MaxPermSize=1024M
> -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
>
> still i get the permgen error exception everyday, pl. someone help, i have
> about 7 applications in struts running on the server, the applications are
> in struts 1.2 , mysql, tomcat 5.5, and are not big applications with about
> only a few jsps.
>
> I consider the applications written properly, pl. help,
>
A few things that can fill PermGen space are...
- repeated re-deployment of applications in tomcat
- dynamically generating classes/JSP pages
- doing really weird stuff with the classloader(s)

Unless you are doing any of the above, I would try and monitor PermGen space
usage in jconsole for a while. You might also want to consider separating those
applications into several tomcat instances to narrow down the cause.

Cheers,
 Edmund

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



Re: OutOfMemoryError: PermGen space!!!! Dont know why?

2010-09-15 Thread Peter McNeil
Check the process for java has the correct max perm size set. If you're 
using linux do a


ps axf --cols 1000 | grep java

A max PermSize of 1024m is pretty big...
My tomcat 6 instance running several apps returns:-

 /usr/java/latest/bin/java 
-Djava.util.logging.config.file=/home/pmcneil/apps/tomcat/apache-tomcat-6.0.24/conf/logging.properties 
-server -Xmx2000m -XX:MaxPermSize=400m 
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 
-Djava.endorsed.dirs=/home/pmcneil/apps/tomcat/apache-tomcat-6.0.24/endorsed 
-classpath 
/home/pmcneil/apps/tomcat/apache-tomcat-6.0.24/bin/bootstrap.jar 
-Dcatalina.base=/home/pmcneil/apps/tomcat/apache-tomcat-6.0.24 
-Dcatalina.home=/home/pmcneil/apps/tomcat/apache-tomcat-6.0.24 
-Djava.io.tmpdir=/home/pmcneil/apps/tomcat/apache-tomcat-6.0.24/temp 
org.apache.catalina.startup.Bootstrap start


and my JAVA_OPTS is ...
echo $JAVA_OPTS
-server -Xmx2000m -XX:MaxPermSize=400m

If that all looks OK you have a memory leak, try using jconsole and look 
at threads and deadlocks etc.


Good luck,
Peter.

On 15/09/10 16:28, abhishek jain wrote:

Hi,
i have the following in bin/catalina.sh

   JAVA_OPTS="$JAVA_OPTS -server -Xms512M -Xmx1024M -XX:MaxPermSize=1024M
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"

still i get the permgen error exception everyday, pl. someone help, i have
about 7 applications in struts running on the server, the applications are
in struts 1.2 , mysql, tomcat 5.5, and are not big applications with about
only a few jsps.

I consider the applications written properly, pl. help,

   



--
web: http://nerderg.com
Twitter: http://twitter.com/pmcneil


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



OutOfMemoryError: PermGen space!!!! Dont know why?

2010-09-14 Thread abhishek jain
Hi,
i have the following in bin/catalina.sh

  JAVA_OPTS="$JAVA_OPTS -server -Xms512M -Xmx1024M -XX:MaxPermSize=1024M
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"

still i get the permgen error exception everyday, pl. someone help, i have
about 7 applications in struts running on the server, the applications are
in struts 1.2 , mysql, tomcat 5.5, and are not big applications with about
only a few jsps.

I consider the applications written properly, pl. help,

-- 
Thanks and kind Regards,
Abhishek jain


Re: Memory analysis after 'OutOfMemoryError PermGen space' error induced by redeployments

2009-06-23 Thread Xie Xiaodong
Hello,

http://blogs.sun.com/fkieviet/entry/how_to_fix_the_dreaded
I recommend this article for your reference.



2009/6/23 Timo Meinen | mindmatters 

> Obviously, my screenshot couldn't be attached to the mailinglist, so here
> is it:
>
> http://timomeinen.de/bilder/PermGenSpace.png
>
>
> Best regards
> Timo Meinen
>
> Am 23.06.2009 um 10:26 schrieb Timo Meinen | mindmatters:
>
>  Hello,
>>
>> we host a Tomcat 6 server with several webapps on it. It is used for
>> continuous integration, so the test webapps are deployed often. We run into
>> OutOfMemoryError: PermGen space after some redeployments and cannot find a
>> solution.
>>
>> I connected JConsole remotely and made a screenshot after some
>> redeployments. The screenshot is attached to this mail. After the first
>> redeployment of webapp 1 the PermGen raises to 150MB and after the
>> deployment it is freed to 115 MB, which seems to be ok. However, the second
>> redeployment won't release the PermGen as you can see on the screenshot.
>> After that, every redeployment will take another 40MB of PermGen space wich
>> leads to the OutOfMemory error, because we set the MaxPermSize to 256m.
>>
>> I tried a manual GC, but this worked only once (see screenshot). After
>> this, the GC was useless.
>>
>>
>> The start parameters of the tomcat server are:
>>
>> -server -Xmx1g -XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled
>> -Djava.awt.headless=true
>> -javaagent:org.springframework.instrument-3.0.0.M2.jar
>>
>>
>> The stacktrace is:
>>
>> SEVERE: org/springframework/web/context/request/AbstractRequestAttributes
>> java.lang.OutOfMemoryError: PermGen space
>>at java.lang.Class.getDeclaredMethods0(Native Method)
>>at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
>>at java.lang.Class.getDeclaredMethod(Class.java:1935)
>>at
>> java.io.ObjectStreamClass.getPrivateMethod(ObjectStreamClass.java:1382)
>>at java.io.ObjectStreamClass.access$1700(ObjectStreamClass.java:52)
>>at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:438)
>>at java.security.AccessController.doPrivileged(Native Method)
>>at java.io.ObjectStreamClass.(ObjectStreamClass.java:413)
>>at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:310)
>>at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
>>at
>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
>>at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
>>at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
>>at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>>at
>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
>>at java.util.ArrayList.writeObject(ArrayList.java:570)
>>at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>at java.lang.reflect.Method.invoke(Method.java:597)
>>at
>> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
>>at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
>>at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
>>at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>>at
>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
>>at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:274)
>>at
>> sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:315)
>>at sun.rmi.transport.Transport$1.run(Transport.java:159)
>>at java.security.AccessController.doPrivileged(Native Method)
>>at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
>>at
>> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
>>at
>> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
>>
>>
>> And the screenshot:
>>
>>
>>
>>
>>
>> Any help would be great for us. Thank you very much.
>>
>> Timo Meinen
>>
>> --
>>
>> 

Re: Memory analysis after 'OutOfMemoryError PermGen space' error induced by redeployments

2009-06-23 Thread Mark Thomas
Timo Meinen | mindmatters wrote:
> Obviously, my screenshot couldn't be attached to the mailinglist, so
> here is it:
> 
> http://timomeinen.de/bilder/PermGenSpace.png

http://markmail.org/message/fcbvwapt6afyndxn

HTH,

Mark

> 
> 
> Best regards
> Timo Meinen
> 
> Am 23.06.2009 um 10:26 schrieb Timo Meinen | mindmatters:
> 
>> Hello,
>>
>> we host a Tomcat 6 server with several webapps on it. It is used for
>> continuous integration, so the test webapps are deployed often. We run
>> into OutOfMemoryError: PermGen space after some redeployments and
>> cannot find a solution.
>>
>> I connected JConsole remotely and made a screenshot after some
>> redeployments. The screenshot is attached to this mail. After the
>> first redeployment of webapp 1 the PermGen raises to 150MB and after
>> the deployment it is freed to 115 MB, which seems to be ok. However,
>> the second redeployment won't release the PermGen as you can see on
>> the screenshot. After that, every redeployment will take another 40MB
>> of PermGen space wich leads to the OutOfMemory error, because we set
>> the MaxPermSize to 256m.
>>
>> I tried a manual GC, but this worked only once (see screenshot). After
>> this, the GC was useless.
>>
>>
>> The start parameters of the tomcat server are:
>>
>> -server -Xmx1g -XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled
>> -Djava.awt.headless=true
>> -javaagent:org.springframework.instrument-3.0.0.M2.jar
>>
>>
>> The stacktrace is:
>>
>> SEVERE: org/springframework/web/context/request/AbstractRequestAttributes
>> java.lang.OutOfMemoryError: PermGen space
>> at java.lang.Class.getDeclaredMethods0(Native Method)
>> at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
>> at java.lang.Class.getDeclaredMethod(Class.java:1935)
>> at
>> java.io.ObjectStreamClass.getPrivateMethod(ObjectStreamClass.java:1382)
>> at java.io.ObjectStreamClass.access$1700(ObjectStreamClass.java:52)
>> at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:438)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.io.ObjectStreamClass.(ObjectStreamClass.java:413)
>> at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:310)
>> at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
>> at
>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
>>
>> at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
>> at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
>>
>> at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>> at
>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
>> at java.util.ArrayList.writeObject(ArrayList.java:570)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at
>> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
>> at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
>> at
>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
>>
>> at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>> at
>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
>> at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:274)
>> at
>> sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:315)
>> at sun.rmi.transport.Transport$1.run(Transport.java:159)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
>> at
>> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
>> at
>> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
>>
>>
>>
>> And the screenshot:
>>
>>
>>
>>
>>
>> Any help would be great for us. Thank you very much.
>>
>> Timo Meinen
>>
>> -- 
>> ---
>>
>> 

Re: Memory analysis after 'OutOfMemoryError PermGen space' error induced by redeployments

2009-06-23 Thread Timo Meinen | mindmatters
Obviously, my screenshot couldn't be attached to the mailinglist, so  
here is it:


http://timomeinen.de/bilder/PermGenSpace.png


Best regards
Timo Meinen

Am 23.06.2009 um 10:26 schrieb Timo Meinen | mindmatters:


Hello,

we host a Tomcat 6 server with several webapps on it. It is used for  
continuous integration, so the test webapps are deployed often. We  
run into OutOfMemoryError: PermGen space after some redeployments  
and cannot find a solution.


I connected JConsole remotely and made a screenshot after some  
redeployments. The screenshot is attached to this mail. After the  
first redeployment of webapp 1 the PermGen raises to 150MB and after  
the deployment it is freed to 115 MB, which seems to be ok. However,  
the second redeployment won't release the PermGen as you can see on  
the screenshot. After that, every redeployment will take another  
40MB of PermGen space wich leads to the OutOfMemory error, because  
we set the MaxPermSize to 256m.


I tried a manual GC, but this worked only once (see screenshot).  
After this, the GC was useless.



The start parameters of the tomcat server are:

-server -Xmx1g -XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled - 
Djava.awt.headless=true - 
javaagent:org.springframework.instrument-3.0.0.M2.jar



The stacktrace is:

SEVERE: org/springframework/web/context/request/ 
AbstractRequestAttributes

java.lang.OutOfMemoryError: PermGen space
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethod(Class.java:1935)
	at  
java.io.ObjectStreamClass.getPrivateMethod(ObjectStreamClass.java: 
1382)

at java.io.ObjectStreamClass.access$1700(ObjectStreamClass.java:52)
at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:438)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.ObjectStreamClass.(ObjectStreamClass.java:413)
at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:310)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
1106)
	at  
java 
.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
1509)
	at  
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
1474)
	at  
java 
.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
1392)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
1150)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java: 
326)

at java.util.ArrayList.writeObject(ArrayList.java:570)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at  
sun 
.reflect 
.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at  
sun 
.reflect 
.DelegatingMethodAccessorImpl 
.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)
	at  
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java: 
945)
	at  
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
1461)
	at  
java 
.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
1392)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
1150)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java: 
326)

at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:274)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java: 
315)

at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
	at  
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java: 
535)
	at sun.rmi.transport.tcp.TCPTransport 
$ConnectionHandler.run0(TCPTransport.java:790)



And the screenshot:





Any help would be great for us. Thank you very much.

Timo Meinen

--
---
mindmatters GmbH &  
Co. KG

Neuer Kamp 30
20357 Hamburg - St. Pauli

Fon: +49 40 4840593 0
Fax: +49 40 4840593 9
Website: www.mindmatters.de

Handelsregister: Amtsgericht Hamburg | HRA 97304 | UID DE225251880
Persönl. haftende Gesellschafterin: mindmatters  
Verwaltungsgesellschaft mbH

Amtsgericht Hamburg | HRB 84595 | Geschäftsführer: Frank Schmitz



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


Viele Grüße
Timo Meinen

--
---
 mindmatters GmbH &  
Co. KG

Neuer Kamp 30
20357 Hamburg - St. Pauli

Fon: +49 40 4840593 0
Fax: +49 40 4840593 9
Website: www.mindmatters.de

Handelsregister: Amtsgericht Hamburg | HRA 97304 | UID D

Memory analysis after 'OutOfMemoryError PermGen space' error induced by redeployments

2009-06-23 Thread Timo Meinen | mindmatters

Hello,

we host a Tomcat 6 server with several webapps on it. It is used for  
continuous integration, so the test webapps are deployed often. We run  
into OutOfMemoryError: PermGen space after some redeployments and  
cannot find a solution.


I connected JConsole remotely and made a screenshot after some  
redeployments. The screenshot is attached to this mail. After the  
first redeployment of webapp 1 the PermGen raises to 150MB and after  
the deployment it is freed to 115 MB, which seems to be ok. However,  
the second redeployment won't release the PermGen as you can see on  
the screenshot. After that, every redeployment will take another 40MB  
of PermGen space wich leads to the OutOfMemory error, because we set  
the MaxPermSize to 256m.


I tried a manual GC, but this worked only once (see screenshot). After  
this, the GC was useless.



The start parameters of the tomcat server are:

-server -Xmx1g -XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled - 
Djava.awt.headless=true - 
javaagent:org.springframework.instrument-3.0.0.M2.jar



The stacktrace is:

SEVERE: org/springframework/web/context/request/ 
AbstractRequestAttributes

java.lang.OutOfMemoryError: PermGen space
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethod(Class.java:1935)
	at java.io.ObjectStreamClass.getPrivateMethod(ObjectStreamClass.java: 
1382)

at java.io.ObjectStreamClass.access$1700(ObjectStreamClass.java:52)
at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:438)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.ObjectStreamClass.(ObjectStreamClass.java:413)
at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:310)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
1106)
	at  
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
1509)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
1474)
	at  
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
1392)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
1150)

at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at java.util.ArrayList.writeObject(ArrayList.java:570)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at  
sun 
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 
39)
	at  
sun 
.reflect 
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 
25)

at java.lang.reflect.Method.invoke(Method.java:597)
	at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java: 
945)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
1461)
	at  
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
1392)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
1150)

at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:274)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:315)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
	at  
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
	at sun.rmi.transport.tcp.TCPTransport 
$ConnectionHandler.run0(TCPTransport.java:790)



And the screenshot:






Any help would be great for us. Thank you very much.

Timo Meinen

--
---
 mindmatters GmbH &  
Co. KG

Neuer Kamp 30
20357 Hamburg - St. Pauli

Fon: +49 40 4840593 0
Fax: +49 40 4840593 9
Website: www.mindmatters.de

Handelsregister: Amtsgericht Hamburg | HRA 97304 | UID DE225251880
Persönl. haftende Gesellschafterin: mindmatters  
Verwaltungsgesellschaft mbH

Amtsgericht Hamburg | HRB 84595 | Geschäftsführer: Frank Schmitz



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

Re: Tomcat 5.5 OutOfMemoryError (PermGen space)

2007-12-12 Thread Tim
Sometime Eclipse also crashes on OutOfMemoryError (PermGen space),
regardless of my using memory collecting tool.

On Dec 13, 2007 2:25 PM, Tim <[EMAIL PROTECTED]> wrote:
> I have the same problem.
>
> I use Eclipse 3.3 and tomcat 5.5.25. Eclipse is set to "Build
> Automatically". When I modified the code within Eclipse, it will
> recompile and reload the tomcat context and the memory problem occurs
> here every time.
>
> I put tomcat  in
> ${catalina.home}/conf/Catalina/localhost/appName.xml. It runs on
> localhost and there is only one webapp.
>
> Eclipse.ini
> 
> -showsplash
> org.eclipse.platform
> --launcher.XXMaxPermSize
> 512M
> -vmargs
> -Dosgi.requiredJavaVersion=1.5
> -Xms512M
> -Xmx1024M
> 
>
> appName.log
> 
> 13/12/2007 14:14:30 org.apache.catalina.core.StandardContext reload
> INFO: Reloading this Context has started
> 13/12/2007 14:14:32 org.apache.catalina.loader.WebappClassLoader 
> validateJarFile
> Exception in thread "Timer-0" java.lang.NullPointerException
>at org.apache.log4j.LogManager.getLogger(LogManager.java:179)
>at org.apache.log4j.Logger.getLogger(Logger.java:94)
>at 
> org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:229)
>...
>...
> 
> Sometimes it reports Java OutOfMemory exception (java heap Space). I
> can't figure out whose problem it is, Eclipse? tomcat, or the code.
>
>
>
> On Dec 13, 2007 12:04 PM, David Wall <[EMAIL PROTECTED]> wrote:
> >
> > >
> > > After some times, my Tomcat will stop responding and the stdout log
> > > says OutOfMemoryError!
> > >
> > You could try increasing the perm space with the Java option:
> > -XX:MaxPermSize=256m
> >
> > Obviously, you can choose any value you want.  We've seen the same
> > problem on systems that have lots of webapps that are reloaded or newly
> > deployed.  From time to time, we have to restart Tomcat 5.5 to get
> > everything clean as we run lots of webapps (50-100) in a single Tomcat
> > instance.
> >
> > David
> >
> >
> >
> > -
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tomcat 5.5 OutOfMemoryError (PermGen space)

2007-12-12 Thread Tim
I have the same problem.

I use Eclipse 3.3 and tomcat 5.5.25. Eclipse is set to "Build
Automatically". When I modified the code within Eclipse, it will
recompile and reload the tomcat context and the memory problem occurs
here every time.

I put tomcat  in
${catalina.home}/conf/Catalina/localhost/appName.xml. It runs on
localhost and there is only one webapp.

Eclipse.ini

-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512M
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms512M
-Xmx1024M


appName.log

13/12/2007 14:14:30 org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
13/12/2007 14:14:32 org.apache.catalina.loader.WebappClassLoader validateJarFile
Exception in thread "Timer-0" java.lang.NullPointerException
at org.apache.log4j.LogManager.getLogger(LogManager.java:179)
at org.apache.log4j.Logger.getLogger(Logger.java:94)
at 
org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:229)
...
...

Sometimes it reports Java OutOfMemory exception (java heap Space). I
can't figure out whose problem it is, Eclipse? tomcat, or the code.


On Dec 13, 2007 12:04 PM, David Wall <[EMAIL PROTECTED]> wrote:
>
> >
> > After some times, my Tomcat will stop responding and the stdout log
> > says OutOfMemoryError!
> >
> You could try increasing the perm space with the Java option:
> -XX:MaxPermSize=256m
>
> Obviously, you can choose any value you want.  We've seen the same
> problem on systems that have lots of webapps that are reloaded or newly
> deployed.  From time to time, we have to restart Tomcat 5.5 to get
> everything clean as we run lots of webapps (50-100) in a single Tomcat
> instance.
>
> David
>
>
>
> -
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tomcat 5.5 OutOfMemoryError (PermGen space)

2007-12-12 Thread David Wall




After some times, my Tomcat will stop responding and the stdout log
says OutOfMemoryError!
  
You could try increasing the perm space with the Java option: 
-XX:MaxPermSize=256m


Obviously, you can choose any value you want.  We've seen the same 
problem on systems that have lots of webapps that are reloaded or newly 
deployed.  From time to time, we have to restart Tomcat 5.5 to get 
everything clean as we run lots of webapps (50-100) in a single Tomcat 
instance.


David


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Tomcat 5.5 OutOfMemoryError (PermGen space)

2007-12-12 Thread Caldarale, Charles R
> From: hezjing [mailto:[EMAIL PROTECTED] 
> Subject: Tomcat 5.5 OutOfMemoryError (PermGen space)
> 
> After some times, my Tomcat will stop responding and the stdout log
> says OutOfMemoryError!

Check the FAQ:
http://wiki.apache.org/tomcat/FAQ/Memory

Especially this link from the above:
http://opensource2.atlassian.com/confluence/spring/pages/viewpage.action
?pageId=2669

> May I know how can I run jvmstats with Tomcat 5.5.25?

You might find JConsole easier.  Just set -Dcom.sun.management.jmxremote
when you start Tomcat.  Lambda Probe also has a useful but less detailed
heap usage display.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Tomcat 5.5 OutOfMemoryError (PermGen space)

2007-12-12 Thread hezjing
Hi

I'm developing a web application using Tomcat 5.5.25 and Spring 2.0.7.

During the development, I frequently use Ant to create WAR, undeploy
and deploy the application to Tomcat. Then simply pressed F5 to
refresh IE to reload the application.

After some times, my Tomcat will stop responding and the stdout log
says OutOfMemoryError!

2007/12/12 23:09:38 ERROR [http-8080-Processor25] StandardContext -
Exception sending context initialized event to listener instance of
class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sessionFactory' defined in ServletContext
resource [/WEB-INF/applicationContext.xml]: Invocation of init method
failed; nested exception is java.lang.OutOfMemoryError: PermGen space
Caused by:
java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at 
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1852)
at 
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:876)
at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1329)
at 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1208)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at org.hibernate.property.MapAccessor.getSetter(MapAccessor.java:24)
at 
org.hibernate.tuple.entity.DynamicMapEntityTuplizer.buildPropertySetter(DynamicMapEntityTuplizer.java:54)
at 
org.hibernate.tuple.entity.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:107)
at 
org.hibernate.tuple.entity.DynamicMapEntityTuplizer.(DynamicMapEntityTuplizer.java:33)
at 
org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:45)
at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:295)
at 
org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:434)
at 
org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:109)
at 
org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at 
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at 
org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
at 
org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
at 
org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1198)
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1167)
at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:285)
at 
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)



This problem was posted in
http://forum.springframework.org/showthread.php?t=47376, but I think
it is more appropriate to discuss here.

May I know how can I run jvmstats with Tomcat 5.5.25?


-- 

Hez

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]