Why is Tomcat not reserving minimum heap space - java

I am running Tomcat 6 on Linux and set Xms and Xmx in setenv.sh. After starting the Tomcat server I don't see the memory usage increased by at least specified in Xms.
Before startup free -m is showing 1500 as free memory.
In my startup.sh I can see memory settings.
CATALINA_OPTS: -Xms512m -Xmx1024m
After server startup free -m is showing 1140 as free memory. Why free memory is not reduced by at least 512m?
jinfo 14064 is showing VM Flags: -Xms512m -Xmx1024m
jmap -heap is also showing memory settings are applied
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 1073741824 (1024.0MB)
Is there anything I am missing?

free -m command
http://www.linuxtoday.com/upload/understanding-free-command-in-linuxunix-130530185004.html
This command will show Actual free RAM.
RAM memory and Virtual memory are different.
Actual initial heap size and max heap size can be allocation by heap
could be identified with the following command.
add the following jvm argument -verbose:gc
and restart the server. Once the server is restarted and after initialization the verbose logs shows the following
// attribute name="maxHeapSize" value="0x40000000"
//attribute name="initialHeapSize" value="0x20000000"
Converting the value into the MB it will show the Xms and Xmx allocation.
Above shown is the snippet of the following command
java -Xms512M -Xmx1024M -verbose:gc -version

Related

JVM committed heap memory is more than Xmx

I have these jvm param set
-Xms24g -Xmx24g -XX:+UseG1GC -XX:+AggressiveOpts -XX:+UnlockCommercialFeatures -XX:+UnlockExperimentalVMOptions -XX:InitiatingHeapOccupancyPercent=17 -XX:G1MaxNewSizePercent=75 -XX:+FlightRecorder -XX:+PrintCommandLineFlags
But In my heap statistics it shows . How can committed be more than Xmx?
in jconsole it shows values in GB
GB to GiB
Multiply by (1000³ / 1024³), equivalent to 0.931323
Divide by this value to go from GiB to GB
25.8*0.931323 = 24.0281334

memory use in docker exceed the xmx control or less than xms

in my docker file
JAVA_OPTS = "-server -Xms512m -Xmx1024m -XX:HeapDumpPath=/opt/logs/dump"
ps aux | grep 18657
root 18657 29.6 4.5 4865248 1477012 ? Ssl 17:26 12:22 /usr/lib/jvm/default-jvm/bin/java -Djava.util.logging.config.file=/apache-tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -server -Xms512m -Xmx1024m
the thread memory 1477012 is more than 1G
so my question is : 600m more memory are noheap memory and how can i find out what is using it
also when i set JAVA_OPTS = "-server -Xms2048m -Xmx3072m -XX:HeapDumpPath=/opt/logs/dump"
when the docker container run and i find the java thread memory is less than 2g.
in my mind, xms is the start heap memory, java thread memmory using can not less the xms

Jenkins heap space

I'm running Jenkins on Windows 2016 server with the following defenitions in jenkins.xml:
-Xrs -Xmx2G -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"
But the problem that we get an error:
exception while collecting data: java.lang.OutOfMemoryError: Java heap space java.lang.OutOfMemoryError: Java heap space
and the server stuck.
After monitorung the master, we have seen that java heap is 512 and not 2G. How can it be?
From the Master monitor screen:
OS: OS Windows NT (unknown), , x86/32 (4 cores)
Java: Java(TM) SE Runtime Environment, 1.8.0_66-b18
JVM: Java HotSpot(TM) Client VM, 25.66-b18, mixed mode The server mode has much better performance than the client mode, you should consider using the server mode if your are not in development
PID of process: 7960
Server: Server jetty/9.2.z-SNAPSHOT
Webapp context:
Start: 11/28/17 2:15 PM
JVM arguments: -Xrs
-Xmx2G
-Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle
-Xmx512M
Mean age of http sessions (min): 6
Memory: Non heap memory = 83 Mb (Perm Gen, Code Cache),
Buffered memory = 0 Mb,
Loaded classes = 22,254,
Garbage collection time = 6,007 ms,
Process cpu time = 156,718 ms,
Committed virtual memory = 438 Mb,
Free physical memory = 13,245 Mb,
Total physical memory = 16,383 Mb,
Free swap space = 16,199 Mb,
Total swap space = 19,327 Mb
Please note that you have 2 options -Xmx in the monitor screen.
Beside verifying what's in jenkins.xml file, have a look at environment variable(s) like:
JAVA_OPTS, MAVEN_OPTS or ANT_OPTS.

Increasing memory through terminal in linux through "-XX:PermSize=192m -XX:MaxPermSize=2g -Xms2g -Xmx2g"

I am running java developer IDE and in a process of trouble shooting a module . For this i have increased the logging memory of the tool, Now when logging it error is coming on console as
Uncaught exception
java.lang.OutOfMemoryError: Java heap space
i am using below command for increasing memory
"-XX:CompileThreshold=8000 -XX:PermSize=192m -XX:MaxPermSize=2g -Xms2g -Xmx2g"
earlier it is
"-XX:CompileThreshold=8000 -XX:PermSize=192m -XX:MaxPermSize=1024m -Xms1024m -Xmx1024m"
my system memory is 16 GB through the command cat /proc/meminfo
but the system free memory is less than 1 GB when exception
Uncaught exception
java.lang.OutOfMemoryError: Java heap space
is coming , I have allocated maximum memory to be utilized as 2gb
-XX:MaxPermSize=2g
but it is occupying approximately all available memory.
Do not know whether this command is help full or not whether could i assign more memory like below command
"-XX:CompileThreshold=8000 -XX:PermSize=192m -XX:MaxPermSize=10g -Xms10g -Xmx10g"
increasing it to 10g will be good or not , or is there any problem with my command.
Use -Xms1024m -Xmx1024m to control your heap size (1024m is only for demonstration, the exact number depends your system memory). Setting minimum and maximum heap size to the same is usually a best practice since JVM doesn't have to increase heap size at runtime

How to decrease java heap size?

I've got an app which is running on JBoss. The server's RAM is too low (about 2gb), so I need to decrease Java heap size. Also I've got 2 versions of Java : system version(1.4.2) and 1.7.0 for JBoss 7 only.
So, how can I decrease Java heap size properly?
There are two flags to control the heap size: -Xms128m will start your heap at 128 megs, and -Xmx1g controls the maximum size (here, it would set it to 1 gig).
You can change the heap size in jboss startup file, edit bat or sh file and search for -Xms and change it to your required size.
Default size of Heap space in Java is 128MB on most of 32 bit Sun's JVM and default values of heap size parameters on 64-bit systems have been increased up by approximately 30%.
You can use
java -XX:+PrintFlagsFinal -version | grep HeapSize
to check your default size.
Read more
You can change size of heap space by using JVM options -Xms and -Xmx. Xms denotes starting size of Heap while -Xmx denotes maximum size of Heap in Java.
You can use
java -Xms1024M -Xmx2048M YourApp
Or edit the /bin/run.sh|exe file by searching for “Sun JVM memory allocation pool parameters” and changing the JAVA_OPTS line:
set JAVA_OPTS=%JAVA_OPTS% -server -Xms1152m -Xmx1152m -XX:MaxPermSize=128m
-XX:MaxNewSize=128m

Categories