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 Tue, 23 Feb 2016 08:37:23 GMT
On 22.02.2016 17:49, Gokul.Baskaran wrote:
> Andre,
> Thanks for getting granular. Let me explain to the items which could have sounded to
be confusing..
> The JVM in discussion is Oracle JVM.
> OS is the 64bit Windows 2012. - OS has 6GB - OS should not impose a limit on memory (Only
in this specific case, as OS is 64bit and total amount of memory available is 6GB) unless
the memory consumption by other processes does not get impacted or grows near 5GB - 6GB limit.
>  From my earlier posts ---
> 	i. It is a Tomcat / Application question as well, as memory default can be configured
in the application config. - Big typo error, it should have been Cannot be configured.

Well yes, that "typo" was a big source of confusion, because everyone was quite puzzled 
about how a java web application would be able to set its Heap-size..

> 	ii. 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 ? - I meant the
JVM heap memory 	given to the application, which is configured in the tomcat instance.

There you go again, with "given to an application".. But I'll let it pass this time, or 
we'll never conclude this thread.
> With respect to the Oracle documentation, if the -Xms and Xmx are not set. The max will
be set to 1/4th which is around 1.5GB of 6 GB	.
> To your point on "There is no Tomcat-Level configuration option" - If I have 2 tomcat
instance on the same OS (Tomcat 1 and Tomcat 2). I can define Xms and Xmx in or in each of the tomcat instances. For example, if Tomcat 1 is configured to have
1GB, JVM heap size for Tomcat 1 will have 1GB and if Tomcat 2 is configured to 2 GB, then
JVM heap size for Tomcat 2 will get 2GB.

Just a little thing here again : the "-Xms" and "-Xmx" options are /not Tomcat options/. 
They are /JVM command-line options/.
And from the OS perspective, you do not have 2 Tomcat instances, you have 2 JVM instances.

Think of it this way : at the moment you start the JVM, what you are starting is a 
OS-level process that is a "virtual machine".  This virtual machine just happens to be one

that is specialised for running java code, instead of machine code.

This virtual machine organises its own memory in a number of areas, and one of these is 
the Heap.  By the "-Xms/-Xmx" command-line parameters of the JVM, you are telling it how 
big that Heap should be, and the JVM will ask the OS for corresponding chunks of memory.

And /then/, once the JVM has started and has allocated memory to the Heap, then you are 
asking this JVM to run a java class that happens to be the class which starts loading 
Tomcat code and running it.

And whatever Tomcat and the Tomcat webapps do after that, they have no influence anymore 
on how much memory is allocated to the Heap (except that by creating lots of objects with

abandon, they could give a hard time to the JVM in managing the Heap and keeping some 
workroom available in there).

And now I think that I can see where the confusion starts maybe on your side : you are 
running this under Windows as a Service, and when you look in the Task Manager, what you 
see running is a process named "tomcat7.exe", and not "java.exe".
And to explain that, you need to read this :

> Yes, it is clear and thanks for explaining.
> -Gokul
> -----Original Message-----
> From: André Warnier (tomcat) []
> Sent: Monday, February 22, 2016 8:37 AM
> To:
> Subject: Re: Tomcat memory
> 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.
> Gokul,
> 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
>>>> 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
>>>>> ics
>>>>> .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
>>>>>       *maximum heap size*
>>>>>           Smaller of 1/4th of the physical memory or 1GB. Before J2SE
>>>>>           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
>>>>>> Thank you
>>>>>> -Gokul

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

View raw message