Why is a java process using so much memory or CPU on my Mac?
Last reviewed: 19 November 2026. The /usr/bin/java launcher and java_home checked on macOS 26.3.1.
A java process is a Java virtual machine running some program, often a build daemon such as Gradle, a language server, a local server, Minecraft Java Edition or a desktop tool. Java reserves a large heap up front and keeps memory until it exits, so high memory is common, and CPU comes from the program's work and garbage collection. The JDK's jcmd command lists Java processes with the main class or JAR they run.
java at a glance
| java | |
|---|---|
| Made by | The Java runtime (OpenJDK builds from Oracle and others) |
| Type | Java virtual machine process |
| Location | /Library/Java/JavaVirtualMachines/[jdk]/Contents/Home/bin/java |
| Runs as | your user |
| Can you quit it? | Yes, but the program it runs stops. Identify it first; build daemons can be stopped with their own command. |
What is java?
macOS does not include Java. /usr/bin/java is a launcher for a JDK installed in /Library/Java/JavaVirtualMachines; with none installed, /usr/libexec/java_home reports that it is unable to locate a Java Runtime. /usr/libexec/java_home -V lists the JDKs it can find.
Many apps bundle their own Java runtime, so a java process may run from inside an app's bundle or from a tool's cache folder. Apps such as IDEs that ship their own runtime often appear under the app's name instead of java.
Is java safe?
The Java runtime is safe; check what it is running. A java process you cannot link to a tool, project, game or app you use deserves a look at its command line.
Why does java use so much memory and CPU?
- Gradle and other build daemons. Gradle keeps a daemon JVM alive between builds so later builds start faster. Gradle's documentation says it stops after 3 hours idle or when system memory runs low.
- A large heap. The JVM manages its own heap, and programs started with large maximum heap settings can grow to that size and keep it.
- Garbage collection. When a program creates many objects or is close to its heap limit, the garbage collector runs often and uses CPU on several threads.
- Servers, games and language servers. Local servers, Minecraft Java Edition and Java-based language servers in editors run continuously while they are open.
How much memory is normal for java?
Hundreds of megabytes to several gigabytes of memory is typical for a JVM, depending on the program and its heap settings. Memory that stays flat after the program warms up is normal.
CPU should fall to near 0% when the program is idle, as a build daemon between builds is.
How do you find out what a java process is running?
- List Java processes. Run
jcmd(orjcmd -l) in Terminal. The JDK documentation says it lists the JVM process IDs with the main class and command-line arguments used to start each one. - Read its command line and parent. Run
ps -o pid,ppid,args -p <PID>. Look for-jar, a main class such asGradleDaemon, and heap options like-Xmx. - Stop Gradle daemons. Run
gradle --statusto list daemons, andgradle --stop(or./gradlew --stopin a project) to stop them. - Look inside a busy JVM.
jcmd <PID> Thread.printprints every thread's stack andjcmd <PID> GC.heap_infoshows the heap, which tells you whether the CPU is the program or the garbage collector.
When should you worry about java?
A java process that starts at login, which you cannot link to any tool or app, should be traced through its command line and any job in ~/Library/LaunchAgents that starts it.
Memory that grows steadily over hours until the program slows down is a sign of a memory leak in that program.
How do you check java in Activity Monitor and Terminal?
Open Activity Monitor (Applications > Utilities), and type java in the search field. The Memory tab shows its Memory. The CPU tab shows its % CPU. Double-click the row for its parent process, memory details and open files.
In Terminal, the first command lists every java process with its PID, user, CPU and memory (RSS is resident memory in kilobytes).
ps -axo pid,user,%cpu,%mem,rss,command | grep -F 'java' | grep -v grep
How can Thrum help with java?
Thrum's Memory tab shows memory pressure, swap, and the eight processes using the most memory, so you can see how much java holds and whether the Mac is short of memory. An optional alert tells you when memory pressure turns critical. Click java in the list for its PID, threads and memory, and Quit or Force Quit it after a confirmation.
Thrum is $4.99 once with a 14-day free trial and no account. It requires macOS 26 Tahoe on Apple silicon or Intel.
Questions about java
Why does java use so much memory even when idle?
The JVM sizes its heap for the program and does not return all of it to macOS right away, so an idle JVM can still show a large footprint.
Does my Mac need Java?
macOS does not need it. You only need a JDK for the apps or tools that run on Java.