You are here : Home / Core Java Tutorials / Series of JVM and Garbage Collection (GC) in java - Best explanations ever
In this tutorial we will learn what are vmid and jps and how to find vmid using JPS.
Contents of page >
- What is vmid?
- What is jps?
- 1) First Write java program - (we will find vmid i.e. jvm id on which this program is running)>
- 2) Use jps to find the vmid
- What is jps?
- Location of jps?
- Go to CMD and type below commands to use JPS>
What is vmid?
Vmid is process id of running JVM.
What is jps?
JPS is Java Virtual Machine Process Status Tool.
1) First Write java program - (we will find vmid i.e. jvm id on which this program is running)>
import java.util.ArrayList;
import java.util.List;
public class JstatTestingGarbageCollectionExample {
public static void main(String[] args) {
List<String> l = new ArrayList<String>();
for (int i = 0; i < 100000000; i++) {
l = new ArrayList<String>();
l.add("a");
System.out.println(l);
}
System.out.println("Done");
}
}
|
Execute the above java program. And this program will take long time to complete (Because of for loop).
And while program is executing follow step 2 to find vmid (i.e. before program execution completes - If we execute below steps after programs execution is over - output will be command not found).
2) Use jps to find the vmid
Location of jps?
jps is located in {javaHome\bin}
In my system jps is located in C:\Program Files\Java\jdk1.8.0_05\bin\jps.exe
Go to CMD and type below commands to use JPS>
C:\>cd C:\Program Files\Java\jdk1.8.0_05\bin
C:\Program Files\Java\jdk1.8.0_05\bin>jps
16048
1108 JstatTestingGarbageCollectionExample
23208 Jps
C:\Program Files\Java\jdk1.8.0_05\bin>
|
1108 is the vmid for which we were looking for.
Also read : How to find out PID (process ID) of processes running in Windows using task manager and CMD
Summary -
So in this core java tutorial we learned What are vmid and jps and how to find vmid using JPS.
Having any doubt? or you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.
RELATED LINKS>
Different type of garbage collectors in java>
>Serial collector / Serial GC (Garbage collector) in java
>Throughput GC (Garbage collector) or Parallel collector in java
>Concurrent Mark Sweep (CMS) collector / concurrent low pause garbage collector in java
>G1 garbage collector / Garbage first collector in java
JVM in detail - Garbage collection & heap structure >
>JVM Heap memory (Hotspot heap structure) with diagram in java
>What are Minor, Major and Full garbage collection in JVM in java
Important VM parameters >
>Most important and frequently used VM (JVM) PARAMETERS with examples in JVM Heap memory in java
>What are -XX:PermSize and -XX:MaxPermSize JVM parameters with examples in java | Differences
>Solve java.lang.OutOfMemoryError : unable to create new native Thread - Xss JVM option
More VM parameters >
>How to use -verbose:gc VM argument
>-Xverify option in java
Monitor, analyze garbage collection and fix MEMORY LEAK >
>How to monitor and analyze the garbage collection in 10 ways in java
>Detecting and fixing memory leak in java
Pass VM para through CMD, eclipse to java program and to Apache tomcat >
>How to write java program to pass VM/JVM parameters through CMD
>How to pass vmArgs(JVM parameters) to java program in eclipse
>How to pass VM argument to tomcat in eclipse
Few more garbage collection and JVM related tutorials>
What is Java Native Interface(JNI)
Find which garbage collector you are using through cmd and java program
Labels:
Core Java
Garbage collection in java