JVM and Java Linux process
21,168
Solution 1
Yes, that's correct. There is one JVM per java
process.
Solution 2
You can run the jps
command (from the bin folder of JDK if it is not in your path) to find out what java processes (JVMs) are running on your machine.
Author by
Gnanam
Updated on July 09, 2022Comments
-
Gnanam almost 2 years
This question may be very basic about Java JVM. If I've a Java standalone program and if, for example, 5 processes of this program are running at a particular time in the server, can we say that these 5 java processes are running in 5 JVMs?
By process, I mean the Linux process here. If I execute
ps -ef |grep java
, I'll see 5 java processes showing up. -
Gnanam over 13 yearsCan we say # of java processes equals # of JVMs running at all cases?
-
Matthew Flaschen over 13 yearsIn a normal Linux setup, as described in your question. There are possible solutions for attempting more than one JVM per process. See this (old) article, for instance.
-
Matthew Flaschen over 13 yearsOn Linux, the JVM uses true native threads, which are similar to processes. However, they are not the same thing, as only a process has its own address space.
-
Matthew Flaschen over 13 yearsI'm addressing your last paragraph. I think you can say that (process count does equal JVM count) for sure, regardless of
ps
output. -
CruiZen over 12 years@Gnanam : You will find the
jps
command useful in another situation. It is normally used to find out the process id of your java process, which can be passed to an application like a profiler like VisualVM (invoked withjvisualvm
comamnd) or thejhat
utility to take heap dumps. -
Gnanam over 12 yearsThanks once again for letting me know the existence of another Heap Analysis tool
jhat
.