You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mike Seda <mi...@lillegroup.com> on 2015/01/21 20:59:35 UTC

DisableExplicitGC

Is it advisable to have the following JVM option set in Tomcat 7 (with
Java 7)?
-XX:+DisableExplicitGC

Or will this prevent Tomcat itself from calling System.gc() when it
needs to?

Mike

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


Re: DisableExplicitGC

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

André,

On 1/21/15 3:13 PM, André Warnier wrote:
> Mike Seda wrote:
>> Is it advisable to have the following JVM option set in Tomcat 7
>> (with Java 7)? -XX:+DisableExplicitGC
>> 
>> Or will this prevent Tomcat itself from calling System.gc() when
>> it needs to?
>> 
> 
> Tomcat is probably not doing that anyway (I'll let someone else
> answer that part), but there might be some monitoring/control
> application running, which could be using that.
> 
> 
> The reason I am thinking of this, is that I have a couple of 
> installations where because of an unruly webapp leaving tons of 
> connections open in CLOSE_WAIT state, I am using a jmxsh script 
> regularly, to provoke such GC's to clean them up. If I set the
> option above, that script would probably fail, and the system would
> slowly get to an inoperative state.

I'm interested... if you add -XX:+DisableExplicitGC and try your
JMX-based gc-caller, does it still invoke the gc?

I know that sounds stupid, but I wonder if the JMX bean's "gc" method
just calls System.gc() or if it uses something under the covers that
will still work.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJUwAt5AAoJEBzwKT+lPKRY6oUP/jSwhawcq18sOid3ESIODrEO
DLOCxw+EOTbiuxcpYfc0F0Wy4wokMeSpB4Yst/vhi/fli8li9458XqmL/X6AqpHA
BMQL2vq0ZFxZokgk/9sZ2CuARmmKUjQwNZl86Dl3sbSV7o/uPoM/FJ5s7MmZkefC
dWESL8UgkKyywAVmHnh9bNwQeQtv762U82aEECQZewo2zx7rx7xWDnMDGmmLGgqe
QwHlBMw7Mwh9GLbQJ9F4tUA4OhMAqJivXVpb2YN+m1CBURJywLYYzye0ayUORfyt
Wyk5iw/g048tykmyotTucDuEF8L87vd2xBEBjgL8w1gFWU4jhg8II0/MBmYgafrz
p6qcE3jl6bH2Qmaf4Wt0+nLNLwWat4J4LhDjqCbY0Q4QeBeEC0Iw7PPFGPYnZKyR
xJtLxMMq5XMq1JupKfdh/2qInPxqv3h3PkKOCCJVDy/Zo2PT5fViN5mktNEBuBQa
17lITWm9IwpR41xHFvz21fWGMTSx8/EhWj7qsNWz4CiephrHpPXr1p3HV+jG9EnK
vV06cgDnBi9UprvbtbF+qVRabMBGq2Idr4JnTY8muG+QShC7UYDeRWrlSXm/4rU7
oBPuCh1PfI0qiz7saOaAn1Dyq8ZsW3sfG7vRfPYVNBM/ow20X8p5oFhMopYYYxYn
ScJqskl/HxOdD2nUiq65
=wqJr
-----END PGP SIGNATURE-----

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


Re: DisableExplicitGC

Posted by André Warnier <aw...@ice-sa.com>.
Mike Seda wrote:
> Is it advisable to have the following JVM option set in Tomcat 7 (with
> Java 7)?
> -XX:+DisableExplicitGC
> 
> Or will this prevent Tomcat itself from calling System.gc() when it
> needs to?
> 

Tomcat is probably not doing that anyway (I'll let someone else answer that part), but 
there might be some monitoring/control application running, which could be using that.


The reason I am thinking of this, is that I have a couple of installations where because 
of an unruly webapp leaving tons of connections open in CLOSE_WAIT state, I am using a 
jmxsh script regularly, to provoke such GC's to clean them up.
If I set the option above, that script would probably fail, and the system would slowly 
get to an inoperative state.

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


Re: DisableExplicitGC

Posted by Mark Thomas <ma...@apache.org>.
On 21/01/2015 19:59, Mike Seda wrote:
> Is it advisable to have the following JVM option set in Tomcat 7 (with
> Java 7)?
> -XX:+DisableExplicitGC

That should be fine. Apps really should not be calling that.

> Or will this prevent Tomcat itself from calling System.gc() when it
> needs to?

Tomcat only calls it in two places - both diagnostic tools. It will
never get called in normal operation.

Mark


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


Re: DisableExplicitGC

Posted by Daniel Mikusa <dm...@pivotal.io>.
On Wed, Jan 21, 2015 at 3:51 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Daniel,
>
> On 1/21/15 3:16 PM, Daniel Mikusa wrote:
> > On Wed, Jan 21, 2015 at 2:59 PM, Mike Seda
> > <mi...@lillegroup.com> wrote:
> >
> >> Is it advisable to have the following JVM option set in Tomcat 7
> >> (with Java 7)? -XX:+DisableExplicitGC
> >>
> >
> > It may or may not make a difference.  Some questions like these
> > come to mind...
> >
> > - How would you feel if one of the applications you deployed
> > called System.gc()? - How about if it called it a lot? or at a
> > really inconvenient time? - How much do you trust your apps or
> > their developers? - Does one of your apps rely on that
> > functionality for some reason?
>
> Our application does not call System.gc automatically, but we have
> that ability through an admin screen where we can say "do GC now", and
> we call it. Sometimes when we have a heap that's been high for a while
> - -- say, tripping our monitoring software a lot -- we go in there and
> hit the GC button to see what happens. Usually, heap usage goes down
> to 25% of what it had been before... it's just that the JVM hadn't
> done a full GC in a while because it didn't need to.
>

I've done that too, but initiated the GC through jvisualvm.

I was wondering if DisableExplicitGC would prevent that as well, so I did a
quick test and it seemed to prevent it.  Guess that's something to consider
too.

Dan


>
> >> Or will this prevent Tomcat itself from calling System.gc() when
> >> it needs to?
> >
> > I really doubt Tomcat would call that.
>
> Tomcat calls System.gc() in only one place --
> StandardHost.findReloadedContextMemoryLeaks -- which is mostly a
> debugging tool.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
> Comment: GPGTools - http://gpgtools.org
>
> iQIcBAEBCAAGBQJUwBFtAAoJEBzwKT+lPKRYiVMP/RAaAjPpKJWio+0I2Zrwnvu1
> xryvw4Ua7DiVzh9ZVFy2NWvw92ReSUWxw6Uf2sKUVOwuC0X5HhnKh7VKtS1fy3h0
> 6zt/o3StQfugEx/lPA7L1uREJOedM1GOHcKeHNKhC3JQUVH2VKELraO+TMYkCiDU
> iiMr7pxoPC/TvCYFKQNgVom5TSEcYi18RL//UU/gBZPk+2ZHV8DbyW0wbLG65Lu2
> FDEZw01tEqrRpIZrRndECL+9NbGEv6vLte1bPEk+2pImcaIKYME+z20ztsa8KfA1
> kbQO6yLvhW4tREH/3SZqfacway4qOxjKQFWqDmkosm7HJXXKlEqsDT+Mi19mTD26
> QvD8aQ6tCp5m6SPG89MN5dk6zHtnjVXrjaVMVx75e0IwSN35aJcUm3g5fTdXLwR6
> vB4U3T958jt5/uD/k9QxJVB15R8+YdU29iBdxKKQ2C86eGa6jUdizaexNPPnaGPi
> R9xrSpHo9JjR/5uC1fIcSgwC6JfVH+j8y5j5Yx87vDllD70IkIgh6wtqxdBmL5as
> 7poC/h8D3TmZwKVtXoAf+DaFIZye9tqxyD8x56XLjVLfBSt9eta0ppunPtqY61KT
> feHBshR7IXvkP29h2rHnP0Yo5abFgQgz8+jFJSmhKpX9CuKtscToCE9Wbgf5ejST
> HZSKRwOUMcCVomv4hTwq
> =WE8p
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: DisableExplicitGC

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Daniel,

On 1/21/15 3:16 PM, Daniel Mikusa wrote:
> On Wed, Jan 21, 2015 at 2:59 PM, Mike Seda
> <mi...@lillegroup.com> wrote:
> 
>> Is it advisable to have the following JVM option set in Tomcat 7
>> (with Java 7)? -XX:+DisableExplicitGC
>> 
> 
> It may or may not make a difference.  Some questions like these
> come to mind...
> 
> - How would you feel if one of the applications you deployed
> called System.gc()? - How about if it called it a lot? or at a
> really inconvenient time? - How much do you trust your apps or
> their developers? - Does one of your apps rely on that
> functionality for some reason?

Our application does not call System.gc automatically, but we have
that ability through an admin screen where we can say "do GC now", and
we call it. Sometimes when we have a heap that's been high for a while
- -- say, tripping our monitoring software a lot -- we go in there and
hit the GC button to see what happens. Usually, heap usage goes down
to 25% of what it had been before... it's just that the JVM hadn't
done a full GC in a while because it didn't need to.

>> Or will this prevent Tomcat itself from calling System.gc() when
>> it needs to?
> 
> I really doubt Tomcat would call that.

Tomcat calls System.gc() in only one place --
StandardHost.findReloadedContextMemoryLeaks -- which is mostly a
debugging tool.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJUwBFtAAoJEBzwKT+lPKRYiVMP/RAaAjPpKJWio+0I2Zrwnvu1
xryvw4Ua7DiVzh9ZVFy2NWvw92ReSUWxw6Uf2sKUVOwuC0X5HhnKh7VKtS1fy3h0
6zt/o3StQfugEx/lPA7L1uREJOedM1GOHcKeHNKhC3JQUVH2VKELraO+TMYkCiDU
iiMr7pxoPC/TvCYFKQNgVom5TSEcYi18RL//UU/gBZPk+2ZHV8DbyW0wbLG65Lu2
FDEZw01tEqrRpIZrRndECL+9NbGEv6vLte1bPEk+2pImcaIKYME+z20ztsa8KfA1
kbQO6yLvhW4tREH/3SZqfacway4qOxjKQFWqDmkosm7HJXXKlEqsDT+Mi19mTD26
QvD8aQ6tCp5m6SPG89MN5dk6zHtnjVXrjaVMVx75e0IwSN35aJcUm3g5fTdXLwR6
vB4U3T958jt5/uD/k9QxJVB15R8+YdU29iBdxKKQ2C86eGa6jUdizaexNPPnaGPi
R9xrSpHo9JjR/5uC1fIcSgwC6JfVH+j8y5j5Yx87vDllD70IkIgh6wtqxdBmL5as
7poC/h8D3TmZwKVtXoAf+DaFIZye9tqxyD8x56XLjVLfBSt9eta0ppunPtqY61KT
feHBshR7IXvkP29h2rHnP0Yo5abFgQgz8+jFJSmhKpX9CuKtscToCE9Wbgf5ejST
HZSKRwOUMcCVomv4hTwq
=WE8p
-----END PGP SIGNATURE-----

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


Re: DisableExplicitGC

Posted by Daniel Mikusa <dm...@pivotal.io>.
On Wed, Jan 21, 2015 at 2:59 PM, Mike Seda <mi...@lillegroup.com> wrote:

> Is it advisable to have the following JVM option set in Tomcat 7 (with
> Java 7)?
> -XX:+DisableExplicitGC
>

It may or may not make a difference.  Some questions like these come to
mind...

  - How would you feel if one of the applications you deployed called
System.gc()?
  - How about if it called it a lot? or at a really inconvenient time?
  - How much do you trust your apps or their developers?
  - Does one of your apps rely on that functionality for some reason?


>
> Or will this prevent Tomcat itself from calling System.gc() when it
> needs to?
>

I really doubt Tomcat would call that.

Dan