tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier (tomcat)>
Subject Re: Tomcat memory
Date Mon, 22 Feb 2016 14:36:35 GMT
On 22.02.2016 13:02, Gokul.Baskaran wrote:
> The answer I expected is the JVM grows as much as to the available system memory of there
are m min and max set.


Well, no.

And because these messages get archived and searched later by other people, they may get 
the wrong conclusion and therefore I will try again.

Re-read your last question.
And then re-read your question before that one.
And then re-read your question before that one.

The problem here is not that you are not being given the information that you want.
The problem is that each time you ask your question, you ask it in a different way, and 
each time somehow in a way that confuses people as to what exactly you want to know.
And the reason why it is confusing is that in your succesive questions you keep on talking

about "application memory" in various ways, but it is not clear what you are referring to

as "application".
For the OS, the JVM is an application.
For the JVM, Tomcat is the application.
And for Tomcat, the web applications (webapps) are the applications.

The JVM is one process that is running on a machine, under an OS.
That OS probably imposes limits on how much resources (including memory) a given process 
is allowed to use.  If a process tries to use more than this, it will be killed with an 
"out of memory" error.  It is unlikely that this per-process limit is "the available 
system memory". The OS will kill the process before it uses all of that.

The JVM itself (of which there are various models on the market) uses memory in various 
ways, for various purposes.  One of these purposes is to manage a Heap, which it makes 
available to Java applications which run inside the JVM.
But the JVM also uses memory for other reasons, such as a stack, and for the code of the 
JVM itself.

For any given JVM, there are (probably) parameters which tell the JVM how much memory it 
should set aside initially for the Heap, and then also for how big it should let the Heap

grow as a maximum.  For the Oracle JVMs, these parameters are "-Xms" and "-Xmx".
By default (if these parameters are not set), the JVM uses some default values, which 
/vary/ depending on the specific JVM and on the circumstances under which it is running 
(the total available machine memory, for example).
For the Oracle JVM, someone already quoted to you the relevant documentation.
For other JVM's, you need to look at the relevant JVM documentation.
(You never indicated which JVM you are using).

The JVM runs java applications (of which Tomcat - the whole Tomcat - is one).  These Java

applications cannot set the amount of memory that they will use in the Heap of the JVM, 
other than indirectly (if they are well-written, the minimum necessary; if they are not 
well-written, who knows).  There is no Tomcat-level configuration option, that allows one

to set how much Heap space Tomcat can use within the JVM Heap.

Then within Tomcat, there are "web applications" running.  Individual web applications 
also cannot set how much Heap they will use, because is not "their" Heap, it is the 
"Tomcat Heap", which itself is not really the Tomcat Heap, it is the JVM's Heap.
That Heap is used by /all/ web applications at the same time.
(That is a bit of an approximation, but ultimately it boils down to that).

So if one of the web applications within Tomcat starts to do things which result in 
filling-up the Heap, and if the JVM cannot clean-up or increase the Heap anymore, there 
will be problems, not only with that web application, but for all web applications and for

the whole Tomcat.

Is that clear, and does it answer your ultimate question ?

>> On Feb 22, 2016, at 2:43 AM, André Warnier (tomcat) <> wrote:
>>> On 22.02.2016 03:44, Gokul.Baskaran wrote:
>>> Thanks again, to make things clear. When I meant default, what is the default
min and max that is given to an application if there nothing defined in the JVM ?
>> In how many different ways do you need to be told this ?
>> Re-read the previous answers that you already received.  All the information is there.
>>> In my case, the Tomcat is running on windows and I don't have setenv.bat or
or even catalina.bat and catalina.conf does not have the OPT config for min and max. HTH
>>> Thank you
>>> -Gokul
>>> -----Original Message-----
>>> From: Olaf Kock []
>>> Sent: Sunday, February 21, 2016 3:04 PM
>>> To: Tomcat Users List <>
>>> Subject: Re: Tomcat memory
>>> grep mx bin/* found only settings in in my installation - this lets
me state that there are no defaults: is not contained in the distribution but will
be read in case it's found in the file system.
>>> Thus there's no tomcat default that I'm aware of. Anybody who distributes tomcat
with a might have a sensible default for their embedded application, but the raw
distribution AFAIK has none.
>>> Safe assumption should be: Whatever the JVM thinks is appropriate is the default.
>>> Create a or setenv.bat and set CATALINA_OPTS to the desired value,
e.g. "-Xms 2048m -Xmx2048m" (but there will probably be more settings, e.g. for tuning the
garbage collector...
>>> (apologies in case this goes out after the problem has long been solved:
>>> I'm in a hotel that blocks SMTP and have to find a way to send mail from
>>> here)
>>> Olaf
>>>> Am 21.02.2016 um 18:23 schrieb Gokul.Baskaran:
>>>> Question was for Java 7
>>>> It is a Tomcat / Application question as well, as memory default can be configured
in the application config.
>>>> I totally agree that the best practice is to set the Xms and -Xmx. As am
going to change the config, I would curious to know if the tomcat ui or the catalina does
not have a Xms and -Xmx, would it default to 400MB? I read this in another forum.
>>>> -Gokul
>>>> -----Original Message-----
>>>> From: Olaf Kock []
>>>> Sent: Sunday, February 21, 2016 3:14 AM
>>>> To: Tomcat Users List <>
>>>> Subject: Re: Tomcat memory
>>>> This is rather a Java than a tomcat question:
>>>> The JVM allocates memory based on whatever default your current JVM
>>>> version decides (you don't mention what version of Java you're on)
>>>>  From a text on
>>>> .html
>>>> that's linked from my Java's manpage:
>>>>      *initial heap size*
>>>>          Larger of 1/64th of the machine's physical memory on the machine
>>>>          or some reasonable minimum. Before J2SE 5.0, the default initial
>>>>          heap size was a reasonable minimum, which varies by platform.
>>>>          You can override this default using the |-Xms| command-line option.
>>>>      *maximum heap size*
>>>>          Smaller of 1/4th of the physical memory or 1GB. Before J2SE 5.0,
>>>>          the default maximum heap size was 64MB. You can override this
>>>>          default using the |-Xmx| command-line option.
>>>>      *Note:* The boundaries and fractions given for the heap size are
>>>>      correct for J2SE 5.0. They are likely to be different in subsequent
>>>>      releases as computers get more powerful.
>>>> Note that this is from JavaSE7 and even mentions 5 - with more power there
comes more initial and maximum memory defaults.
>>>> I'm not aware of the actual development of the default memory - mostly
>>>> because I consider it good practice to know what an application uses
>>>> and provide it explicitly, rather than relying on defaults. (and
>>>> frankly, on the applications that I see, the default typically is not
>>>> even enough - let alone a good basis for tuning)
>>>> While we're at it: For production systems I consider it good practice to
set -Xms and -Xmx to the same value. Reason: If you don't have enough memory available, you
want to know this when the process starts, not days later when it tries to allocate "the rest"
- typically sunday night at 3am.
>>>> Olaf
>>>>> Am 21.02.2016 um 03:39 schrieb Gokul.Baskaran:
>>>>> Hi,
>>>>> I am currently running tomcat 7 in Windows 2012.
>>>>> The current JVM Heap memory parameters are set to empty, does the JVM
Heap memory utilize the entire memory of the OS or does it default to a specific memory number?
>>>>> Thank you
>>>>> -Gokul
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail:
>>>> For additional commands, e-mail:
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail:
>>> For additional commands, e-mail:
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail:
>>> For additional commands, e-mail:
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message