Why is Java using so Much Real Memory?

Solution 1:

This is due to the nature of garbage collection technology used in Java. Freeing memory in such systems is delayed until some threshold reached, or out of memory happens, or some time passes. It is probably not using all those 700MB all the time (may as well be just 50 MB), but Activity Monitor has no way to look inside Java virtual machine and tell how much is actually used.

Normally, if there are no bugs or leaks (yes GC systems may leak too), Java should give up unused memory whenever your system runs out of it, so there is no need to worry right now. Said that, if you don't need the program, it won't hurt uninstalling whatever is starting it up.

Solution 2:

Open up activity monitor, click on the Java process and press Command-I.

From there you might be able to figure out where the process comes from 2 ways

1) Look at open files and ports The open files should give a clue where the process is from or at least what it's reading + writing to.

2) Parent Process You can click on this to open info about the parent process and trace up the parent chain to see what launched the process. If it's launchd, you might be able to look at your launchd config to see where there's a java call in there.

Solution 3:

The archaic explanation:

Java applications require a virtual machine to run because they cannot be are usually not compiled directly into machine language (native code) for many processors, instead Java is usually complied into bytecode. Java is also a very high-level Object-Oriented programming language (OOP) which means that while the application code itself is much easier to maintain, the objects that are instantiated will use that much more memory.

The more modern explanation:

However, many do argue that the problem is usually more so because of the Java program's data structures and architecture, rather than the bytecode. And I tend to agree with that.

There are a number of other reasons why Java apps are using so much system resources (like RAM). For example, most modern applications use the UTF-8 charset, which requires more memory per character, for strings (usually text) as it can support so many other languages' symbols. And since so many applications target a huge international market, they're sorta obligated to use it.

That said, Java arguably remains the most popular programming language at the moment. Many applications that your computer runs are written in Java. That is why.