Each Java process has a pid, which you first need to find with the jps command.

Once you have the pid, you can use jstat -gc [insert-pid-here] to find statistics of the behavior of the garbage collected heap.

  • jstat -gccapacity [insert-pid-here] will present information about memory pool generation and space capabilities.

  • jstat -gcutil [insert-pid-here] will present the utilization of each generation as a percentage of its capacity. Useful to get an at a glance view of usage.

See jstat docs on Oracle's site.

Answer from farmer1992 on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › jvm › command-line tools to find the java heap size
Command-Line Tools to Find the Java Heap Size | Baeldung
January 27, 2024 - For instance, we can use jstat -gc to see heap statistics: $ jstat -gc 4309 S0C S1C S0U S1U EC EU OC OU MC 0.0 0.0 0.0 0.0 129024.0 5120.0 75776.0 10134.6 20864.0 MU CCSC CCSU YGC YGCT FGC FGCT CGC CGCT GCTGCT 19946.2 2688.0 2355.0 2 0.007 1 ...
🌐
W3Docs
w3docs.com › java
How to find Java Heap Size and Memory Used (Linux)? | W3Docs
To find the Java heap size and the amount of memory used on a Linux system, you can use the jstat command and specify the process ID (PID) of the Java process. ... This will display the Java heap size and the amount of memory used, as well as ...
🌐
Quora
ubuntuclub.quora.com › How-to-check-the-Java-heap-size-in-Linux
How to check the Java heap size in Linux - Ubuntu Club - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
🌐
Position Is Everything
positioniseverything.net › home › how to check java heap size in linux: a quick guide
How to Check Java Heap Size in Linux: A Quick Guide - Position Is Everything
December 29, 2025 - When working with Java applications ... has enough gas before a long trip. To check the Java heap size in Linux, use commands like ps, jstat, and jcmd....
🌐
Mkyong
mkyong.com › home › java › find out your java heap memory size
Find out your Java heap memory size - Mkyong.com
March 9, 2014 - Java heap size InitialHeapSize = 64781184 bytes (61.7M) and MaxHeapSize = 1038090240 bytes (990M). PermGen Size PermSize = 21757952 bytes (20.75M), MaxPermSize = 174063616 bytes (166M) Thread Stack Size ThreadStackSize = 1024 kilobytes (1M) The allocated heap memory size is quite close to the ergonomics result.
🌐
Medium
medium.com › @Flashleo › check-and-increase-jvm-heap-size-on-windows-and-linux-machine-bd4e3d0e3b8c
Check and Increase JVM heap size on windows and Linux machine | by Harish K | Medium
August 14, 2020 - Command to find out how much heap size your JVM has: On Windows Machine: Open command prompt and enter below command: java -XX:+PrintFlagsFinal -version | findstr /i “HeapSize PermSize ThreadStackSize” ... To increase the size, I have followed ...
Find elsewhere
🌐
Codemia
codemia.io › knowledge-hub › path › how_can_i_find_java_heap_size_and_memory_used_linux
How can I find Java heap size and memory used Linux?
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises
🌐
javathinking
javathinking.com › blog › how-can-i-find-java-heap-size-and-memory-used-linux
How to Check Java Heap Size and Used Memory on Linux via Command Line — javathinking.com
Metaspace (Java 8+): Replaced "PermGen" to store class metadata (not part of the heap but often monitored alongside it). Configured Heap Size: Defined at JVM startup via flags: -Xms: Initial heap size (e.g., -Xms512m = 512 MB). ... Used Heap Size: The actual memory consumed by the application at runtime, which fluctuates as objects are created and garbage-collected. ... A Linux system (e.g., Ubuntu, CentOS) with a Java application running.
🌐
CodingTechRoom
codingtechroom.com › question › check-java-heap-size-linux-command-line
How to Check Java Heap Size and Memory Usage in Linux via Command Line? - CodingTechRoom
Use the `jps` command to find the process ID (PID) of your Java application. Use the `jcmd` command to retrieve the heap information for the identified Java process.
🌐
UMA Technology
umatechnology.org › home › how to check java heap size and memory usage in linux via command line?
How to Check Java Heap Size and Memory Usage in Linux via Co
To check Java heap size and memory usage in Linux, use jcmd first for effective heap limits (VM.flags) and live heap internals (GC.heap_info).
🌐
Red Hat
developers.redhat.com › articles › 2021 › 09 › 09 › how-jvm-uses-and-allocates-memory
How the JVM uses and allocates memory | Red Hat Developer
October 20, 2023 - Many programmers figure out the maximum heap value for their application's JVM correctly but discover that the JVM is using even more memory. The value of the -Xmx parameter specifies the maximum size of the Java heap, but that is not the only ...
🌐
Unix.com
unix.com › shell programming and scripting
Finding Heap size Command--Urgent - Shell Programming and Scripting - Unix Linux Community
October 18, 2017 - Hi Friends, i need a unix command to check the heap space availability on unix system as I am getting following error: Error occurred during initialization of VM Could not reserve enough space for object heap Error o…
🌐
Azul
docs.azul.com › prime › zst › show-heap-sizes
Showing Available Heap Sizes - Azul Docs
[root@localhost bin]# echo "Zing Available Heapsize (MB) is "`zing-ps --acct|grep Committed|awk '{print int($3/(1024*1024))}'` Zing Available Heapsize (MB) is 3854 [root@localhost bin]# echo "Zing Total Heapsize (MB) is "`zing-ps --acct|grep Committed|awk '{print int($4/(1024*1024))}'` Zing Total Heapsize (MB) is 3854 root 5785 java NAME BALANCE ALLOCATED MAXIMUM FND ODFND account[0]: default 10485760 2097152 12582912 0 1 account[1]: emergency_gc 0 0 0 -1 -1 account[2]: heap 555745280 505413632 1283457024 0 1 account[3]: pause_prevention 0 0 274877906944 3 3 account[4]: unknown 0 0 0 -1 -1 acc
🌐
Lucee Dev
dev.lucee.org › support
Setting Heap Size (Linux Server) - support - Lucee Dev
January 18, 2024 - I could not find this in the Lucee documentation, so I wanted to check how to properly set the heap size on a Linux server (Ubuntu in my case). Is this the proper procedure: 1. Create setenv.sh file Create a file new named setenv.sh in the following location. sudo nano /opt/lucee/tomcat/bin/setenv.sh 2. Add the JAVA_OPTS line In the file, add JAVA_OPTS line with the desired memory values.
🌐
Unix.com
unix.com › unix for beginners q & a › unix for dummies questions & answers
Checking heap memory size for java app - UNIX for Dummies Questions & Answers - Unix Linux Community
July 16, 2010 - Hi I have one Java application installed in my Solaris system. Is there a way to find out the heap memory allocated size/used size/free size for the particular Java process? If anyone knows the command, please let me k…