Using HugePages and -XX:+AlwaysPreTouch makes sure that all memory is
allocated immediately.
We've been using this for years to make sure our Java processes get
access to all memory that would eventually be needed by the heap,
metaspace, etc.
Especially in order to avoid the effects of any unintended swapping,
which effectively kills throughput whenever the garbage collector
happens to run into memory pages that have been swapped out to disk.
*Manuel Dominguez Sarmiento*
On 01/04/2020 10:06, Christopher Schultz wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Jim,
On 3/31/20 23:57, o haya wrote:
I think I figured out what is going on. I think that the
parameters were working all right, but the memory that is shown by
the "free" command isn't corresponding to the JVM memory.
I put together a small JSP that uses
Runtime.getRuntime().totalMemory() and .freeMemory() and and when I
access that page, that shows the JVM memory is as I configured with
the Xmx/Xms.
Yes, this is an error in your interpretation of your observations.
Linux will lie, cheat, and steal in order to manage memory. It does
that because processes lie, cheat, and steal, in order to get the
resources they want. Some process says it needs a couple of gigs of
RAM? Yeah, right, we'll believe it when we see it.
Linux is doing its best to operate in an environment where processes
often say they need resources that they don't actually use. In order
to avoid prematurely running out of resources, the kernel will lie to
the process and say the resources are available but not actually
allocate them until the process tries to USE those resources.
This is a Good Thing. free/ps/top/etc are telling you the truth. Java
doesn't try to allocate the entire heap immediately, so Java thinks it
can have all 4GiB of heap space and it will probably get it. But maybe
not :) [1]
- -chris
[1] https://www.kernel.org/doc/gorman/html/understand/understand016.html
On Tue, Mar 31, 2020 at 10:03 PM o haya <ohaya1...@gmail.com>
wrote:
Hi,
BTW, in the catalina.out log file, I do see these lines:
01-Apr-2020 01:53:17.775 INFO [main]
org.apache.catalina.startup.VersionLoggerListener.log Command
line argument: -Dfile.encoding=UTF-8 01-Apr-2020 01:53:17.775
INFO [main] org.apache.catalina.startup.VersionLoggerListener.log
Command line argument: -Xms4096m 01-Apr-2020 01:53:17.775 INFO
[main] org.apache.catalina.startup.VersionLoggerListener.log
Command line argument: -Xmx4096m 01-Apr-2020 01:53:17.775 INFO
[main] org.apache.catalina.startup.VersionLoggerListener.log
Command line argument: -XX:NewSize=256m 01-Apr-2020 01:53:17.775
INFO [main] org.apache.catalina.startup.VersionLoggerListener.log
Command line argument: -XX:MaxNewSize=256m
So from that logging, it seems like Tomcat IS seeing those
parameters, so why does it not seem to be using the larger
amounts of memory?
Thanks, Jim
On Tue, Mar 31, 2020 at 9:44 PM o haya <ohaya1...@gmail.com>
wrote:
Hi,
I have Tomcat installed in /apps/apache-tomcat-9.0.20/
In the /apps/apache-tomcat-9.0.20/bin/setenv.sh, I have:
#!/bin/bash
JAVA_HOME=/apps/jdk1.8.0_221
CATALINA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8
-server \ -Xms4096m -Xmx4096m -XX:NewSize=256m
-XX:MaxNewSize=256m -XX:+DisableExplicitGC \
-Djava.security.egd=file:/dev/./urandom"
Then to start Tomcat, I:
cd /apps/apache-tomcat-9.0.20/
bin/startup.sh
Here's an example of running:
[root@ip-192-168-218-224 apache-tomcat-9.0.20]# free total
used free shared buff/cache available Mem:
32780604 913012 27429012 16716 4438580
31441736 Swap: 0 0 0
[root@ip-192-168-218-224 apache-tomcat-9.0.20]# cd
/apps/apache-tomcat-9.0.20/ [root@ip-192-168-218-224
apache-tomcat-9.0.20]# [root@ip-192-168-218-224
apache-tomcat-9.0.20]# bin/startup.sh Using CATALINA_BASE:
/apps/apache-tomcat-9.0.20 Using CATALINA_HOME:
/apps/apache-tomcat-9.0.20 Using CATALINA_TMPDIR:
/apps/apache-tomcat-9.0.20/temp Using JRE_HOME:
/apps/jdk1.8.0_221 Using CLASSPATH:
/apps/apache-tomcat-9.0.20/bin/bootstrap.jar:/apps/apache-tomcat-9.0
.20/bin/tomcat-juli.jar
Tomcat started.
[root@ip-192-168-218-224 apache-tomcat-9.0.20]# free total
used free shared buff/cache available Mem:
32780604 1343288 26998784 16716 4438532
31011556
You are right that it appears like it is not using the
CATALINA_OPTS to set the memory, but I don't know why ???
Thanks, Jim
On Tue, Mar 31, 2020 at 12:52 PM Mark Thomas <ma...@apache.org>
wrote:
On 31/03/2020 17:42, o haya wrote:
Thanks for the infos.
I was thinking the same thing you were thinking, that it
might be
32-bit
JVM, but when I run "java -version" I am getting:
java -version java version "1.8.0_221" Java(TM) SE Runtime
Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit
Server VM (build 25.221-b11, mixed mode)
Isn't that confirming that this is a 64-bit JVM?
ALSO FYI, I did test where I also added "-d64" parameter to
the CATALINA_OPTS, and same thing happened.
Exactly how are you setting those? It looks like the changes
you are making aren't having any effect. If you specified a
4Gb min heap on a 32-bit JVM I'd expect Java to either refuse
to start or crash on start.
Mark
Jim
On Tue, Mar 31, 2020 at 11:10 AM Olaf Kock
<tom...@olafkock.de> wrote:
On 31.03.20 17:02, o haya wrote:
Hi,
I am running Tomcat 9.02 under RHEL 7 (under Oracle JDK
1.8), and I
would
like to increase the memory that is available to Tomcat
when it is
running.
I have tried sourcing the following:
JAVA_OPTS="-Djava.awt.headless=true
-Dfile.encoding=UTF-8 -server \ -Xms4096m -Xmx4096m
-XX:NewSize=256m -XX:MaxNewSize=256m
-XX:+DisableExplicitGC \
-Djava.security.egd=file:/dev/./urandom -d64"
You want to use CATALINA_OPTS for memory settings, not
JAVA_OPTS.
JAVA_OPTS are used for every JVM start, including when
you run shutdown.sh - that one needs only a minimal
amount of memory for short time.
and also:
CATALINA_OPTS="-Djava.awt.headless=true
-Dfile.encoding=UTF-8
-server \
-Xms4096m -Xmx4096m -XX:NewSize=256m
-XX:MaxNewSize=256m -XX:+DisableExplicitGC \
-Djava.security.egd=file:/dev/./urandom"
your CATALINA_OPTS will be combined with the JAVA_OPTS,
so that you configure the memory twice.
But -Xms and -Xmx are the way to configure the memory.
but even with those, when I check memory using "free",
it is only
using
about 1.5GB.
Can someone tell me how I can accomplish this?
Sounds suspiciously like you're running on 32bit, either
the OS or
JVM.
Upgrade to 64bit to have access to more memory.
-----------------------------------------------------------------
- ----
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
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl6EkdcACgkQHPApP6U8
pFirhw/+JgLdSM+hgsOcCeifrhT3yG0LgPeoF/qXVxVSbP0slrSxr6dcFXtNfEH/
dvTbcIOk+sHx8e3vzJnLARQ2INpH0AtCQGYd7tR2jEklp/8KfAJYRFYqk93AEwph
guoRiUhs/4xqiG4KnuaOd1JC0PYKjZSSOVDiN9c0zq3808uomJeReyR1tj+NsqQN
fT8xKL5RTCWKcVKCbKpbS0lo0JNLgGTAWfDDmkostq1O8D/QnMYkxtPYLaux1UCv
vhohZGHxcetqkRTsWTW4jbqXQbJ9R+DZ+sahajpWArsUfNvF79Wcw0QHwxiyxlgW
BaIMG3KhGY07nW0FHd93jWkzT58BZ5XJw4K1yryF03QgGyR26tX6Wc95/Q4IgwFA
38eRxiOC3gGeN3TNc6+KmLbtZuoCbi2ajyVDVEzgskWLN069KIdeIcExYSPC1NCF
fqHRf1fPLgrde++tzJjWMWczhdTcsWZQyclhTRX8Fpqkq7mri7c/16T0yDRjrsdK
UKN6a18IC4kX5OhxHg3wS7sYpgqVsjq4RqNZyhz5ideMuTZUOL/24ywtAtRVjram
SFe9Q+hs1kR4MxdaE+8mkpd12cSZ7ScW6vj/80ndw5rQg0C8MCwqi3qQlEC36Huh
sFZq5xEl7hpJkbmZ1OWQIuJKCDqtwnG562JbZ4pYL0uPmwp3r3I=
=Wcgn
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org