You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "André Warnier (tomcat)" <aw...@ice-sa.com> on 2017/03/19 12:37:32 UTC

[OT] Re: Tomcat 8/Redhat Linux 6.6 /Kernal 2.6.32 - Memory Won't Release

On 17.03.2017 14:54, Christopher Schultz wrote:

>
> Note that Java *never* gives any memory back to the OS, even when the
> heap-usage goes down. This is a Java thing, not a Tomcat thing.

I did not know that (*), and I have never seen this mentioned explicitly in any Java 
documentation (not that I have read many).
What is the point of the Java "-Xms" and "-Xmx" command-line parameters then (when they 
have different values).

(*) I thought it was only perl doing that


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


Re: [OT] Re: Tomcat 8/Redhat Linux 6.6 /Kernal 2.6.32 - Memory Won't Release

Posted by "André Warnier (tomcat)" <aw...@ice-sa.com>.
On 20.03.2017 09:36, Olaf Kock wrote:
>
> Am 20.03.2017 um 09:30 schrieb Andr� Warnier (tomcat):
>> One may wonder in fact : if when resizing the Heap downwards, the JVM
>> is anyway not going to give the surplus memory back to the OS, then
>> why bother ? what is the surplus ex-Heap memory then used
>> interestingly for, by the JVM ?
>
> There's no real "resizing the heap downward". There's garbage
> collection, because the heap can't be grown any more (or because it's
> triggered by other means), but this just frees up some heap for more
> objects, it doesn't resize the heap. Some of the garbage collectors
> (predominantly old-generation collectors) do not even compact the heap,
> so that no block could be returned to the OS - and this might be the
> clue we're looking for as to why nothing is ever returned to the OS:
> There's just no contiguous block of memory that could be freed.
>
> Naturally the "surplus" heap (which is the heap freed up in former
> garbage collection) is used for new objects that will be created over time.
>

Thanks for the info.
Maybe it would be worth adding this to the Tomcat FAQ, such as around this page :

https://wiki.apache.org/tomcat/FAQ/Memory

(I did not write that page, so I am a bit reluctant to modify it)


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


Re: [OT] Re: Tomcat 8/Redhat Linux 6.6 /Kernal 2.6.32 - Memory Won't Release

Posted by Olaf Kock <to...@olafkock.de>.
Am 20.03.2017 um 09:30 schrieb Andr� Warnier (tomcat):
> One may wonder in fact : if when resizing the Heap downwards, the JVM
> is anyway not going to give the surplus memory back to the OS, then
> why bother ? what is the surplus ex-Heap memory then used
> interestingly for, by the JVM ?

There's no real "resizing the heap downward". There's garbage
collection, because the heap can't be grown any more (or because it's
triggered by other means), but this just frees up some heap for more
objects, it doesn't resize the heap. Some of the garbage collectors
(predominantly old-generation collectors) do not even compact the heap,
so that no block could be returned to the OS - and this might be the
clue we're looking for as to why nothing is ever returned to the OS:
There's just no contiguous block of memory that could be freed.

Naturally the "surplus" heap (which is the heap freed up in former
garbage collection) is used for new objects that will be created over time.

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


Re: [OT] Re: Tomcat 8/Redhat Linux 6.6 /Kernal 2.6.32 - Memory Won't Release

Posted by "André Warnier (tomcat)" <aw...@ice-sa.com>.
On 19.03.2017 20:33, Olaf Kock wrote:
>
>
> Am 19.03.2017 um 13:37 schrieb Andr� Warnier (tomcat):
>> On 17.03.2017 14:54, Christopher Schultz wrote:
>>
>>>
>>> Note that Java *never* gives any memory back to the OS, even when the
>>> heap-usage goes down. This is a Java thing, not a Tomcat thing.
>>
>> I did not know that (*), and I have never seen this mentioned
>> explicitly in any Java documentation (not that I have read many).
>> What is the point of the Java "-Xms" and "-Xmx" command-line
>> parameters then (when they have different values).
> I can't remember where I've seen it, but it's been ages ago and I assume
> it since eternity.
>
> The difference between -Xms and -Xmx is:
> $ java -X 2>&1 | grep "Java heap size"
>      -Xms<size>        set initial Java heap size
>      -Xmx<size>        set maximum Java heap size
>
> i.e. -Xms only talks about the /initial/, not about the minimal heap size.

Aaah. That may be where my confusion got in, indeed. I was assuming it to be both the 
initial and minimal heap size, and was hitherto assuming that when Java doesn't need such 
a big Heap anymore, it returns the surplus memory to the OS.

>
> In production systems I religiously set both sizes to identical values,
> assuming that otherwise allocation of more than the initial memory will
> fail sunday night at 3am instead of right when the JVM is started.

Yes, so do I, for the same reason, /and/ to save that smidge of overhead which would be 
otherwise due to the Java JVM having to resize the Heap regularly.  Which is another thing 
which I read once somewhere and believed, without ever really having gone to the bottom of it.

One may wonder in fact : if when resizing the Heap downwards, the JVM is anyway not going 
to give the surplus memory back to the OS, then why bother ? what is the surplus ex-Heap 
memory then used interestingly for, by the JVM ?

>
> Olaf
>
>>
>> (*) I thought it was only perl doing that
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


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


Re: [OT] Re: Tomcat 8/Redhat Linux 6.6 /Kernal 2.6.32 - Memory Won't Release

Posted by Olaf Kock <to...@olafkock.de>.

Am 19.03.2017 um 13:37 schrieb Andr� Warnier (tomcat):
> On 17.03.2017 14:54, Christopher Schultz wrote:
>
>>
>> Note that Java *never* gives any memory back to the OS, even when the
>> heap-usage goes down. This is a Java thing, not a Tomcat thing.
>
> I did not know that (*), and I have never seen this mentioned
> explicitly in any Java documentation (not that I have read many).
> What is the point of the Java "-Xms" and "-Xmx" command-line
> parameters then (when they have different values).
I can't remember where I've seen it, but it's been ages ago and I assume
it since eternity.

The difference between -Xms and -Xmx is:
$ java -X 2>&1 | grep "Java heap size"
    -Xms<size>        set initial Java heap size
    -Xmx<size>        set maximum Java heap size

i.e. -Xms only talks about the /initial/, not about the minimal heap size.

In production systems I religiously set both sizes to identical values,
assuming that otherwise allocation of more than the initial memory will
fail sunday night at 3am instead of right when the JVM is started.

Olaf

>
> (*) I thought it was only perl doing that
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


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