On Jan 27, 2014, at 10:36 AM, Арсений Зинченко <setev...@gmail.com> wrote:

> Hi, Dan. Thanks for replay.
> 
>> he JVM is only going to accept one value for Xmx and Xms.  Specifying the
> same options in JAVA_OPTS and CATALINA_OPTS would just be confusing.
> 
> As I says before - we have few Java-application on same machine. So - for
> them needs to set Xmx 1G, but for Tomcat - 4G.

I’m not sure how this is relevant.  I understand that you have multiple 
applications running, but it doesn’t matter.  Each application you run will 
have it’s own JVM with it’s own Xmx and Xms settings.  

If you set Xmx or Xms twice for one JVM, which is essentially what you’re doing 
when you put them in both JAVA_OPTS and CATALINA_OPTS that would just be 
confusing.  It’s won’t directly cause a problem, the JVM will pick one and 
ignore the others, but it’s confusing to someone looking at your configuration.

> 
>> Don’t set these as system variables.  You’d want to define them in
> setenv.bat
>> Again, don’t set system variables for these.  There’s no reason to set
> them system wide.
> 
> Same reason - few Java-applications wich all need same Java_opts (exclude
> Tomcat).

This is just my opinion.  There’s nothing to prevent you from setting these 
values system wide.  I would suggest that you don’t though.  It’s just going to 
be confusing.  Set the values in the configuration for each Java application / 
Tomcat instance.  Then it’s immediately clear which value is being used for 
which application.

> 
>> Since you’re on Windows, you’re probably running as a service and that’s
> going to be a bit different
> 
> No, Tomcat started via command line (rather - from .bat script wich call
> %catalina_home%/bin/startup.bat).

Ok then.  You’ll want to create the file bin/setenv.bat for each of your Tomcat 
instances.  In that file, you can set JAVA_OPTS and / or CATALINA_OPTS.  As I 
mentioned before, I’d suggest putting your heap options in CATALINA_OPTS.

Dan


> 
> 
> 2014/1/27 Daniel Mikusa <dmik...@gopivotal.com>
> 
>> On Jan 27, 2014, at 9:21 AM, Арсений Зинченко <setev...@gmail.com> wrote:
>> 
>>> Hi.
>>> 
>>> I'm sorry for so kindly question - but needs experts advice...
>>> 
>>> We have a little dispute with my colleague about using this variables.
>>> 
>>> So: have Windows-box machine. On it - runing few different
>>> Java-application, including Tomcat.
>>> 
>>> Needs to set memory for Tomcat other, than for all other
>> Java-applications.
>>> 
>>> My proposal is set to System variables:
>>> 
>>> JAVA_OPTS "-Xmx1024M -Xms512M -XX:MaxPermSize512M"
>>> CATALINA_OPTS "-Xmx4096M -Xms2048M -XX:MaxPermSize=1024M”
>> 
>> Don’t set these as system variables.  You’d want to define them in
>> setenv.bat if you’re running from the command prompt or with the Windows
>> Service utility (either [1] or [2]), if you’re running as a service.
>> 
>>> 
>>> But, as he asserts - this is not correct way:
>>> 
>>> 
>>>  - CATALINA_OPTS must NOT contain memory limits like "Xmx", "Xms" etc;
>> 
>> There are no restrictions to what you can set in CATALINA_OPTS.  You could
>> put your memory setting there if you wanted.  Having said that, if you’re
>> running as a Windows service then you wouldn’t.  You'd set your heap memory
>> settings through the service wrapper (either [1] or [2]).
>> 
>> If you’re running from the console (not likely) or on Linux / Unix then
>> you’d set your heap settings in the setenv.sh|bat script.  Again, you could
>> put memory settings in CATALINA_OPTS or in JAVA_OPTS.  Setting them in
>> CATALINA_OPTS is generally a better choice though because settings in
>> CATALINA_OPTS are only applied when Tomcat is started.  If you set them in
>> JAVA_OPTS then they’ll be applied when you start and stop the instance,
>> something you probably don’t want for your heap settings.
>> 
>>>  - Java Garbage collector will work differently because JAVA_OPTS have
>>>  another opts for memory then CATALINA_OPTS, so - this will worse Tomcat
>>>  performance;
>> 
>> I’m not sure I follow your logic here.  The JVM is only going to accept
>> one value for Xmx and Xms.  Specifying the same options in JAVA_OPTS and
>> CATALINA_OPTS would just be confusing.
>> 
>>>  - and so on
>>> 
>>> His suggestion is to set JAVA_OPTS with memory limits exactly to Tomcat
>>> startup script (not as system variable at all).
>> 
>> Again, don’t set system variables for these.  There’s no reason to set
>> them system wide.
>> 
>>> 
>>> So, my question is: is it correct to set memory limits for Tomcat via
>>> CATALINA_OPTS variable?
>> 
>> Generally, but it depends on how you are starting Tomcat.  Since you’re on
>> Windows, you’re probably running as a service and that’s going to be a bit
>> different.  See above comments.
>> 
>>> If in system also present JAVA_OPTS - will it have influence on to
>> Tomcat's performance?
>> 
>> I think I answered this above.  If it’s not clear, let me know.
>> 
>>> 
>>> Thanks.
>> 
>> Dan
>> 
>> [1] -
>> http://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html#Command_line_parameters
>> [2] -
>> http://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html#Tomcat7w_monitor_application
>> 
>> 
>> ---------------------------------------------------------------------
>> 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

Reply via email to