Memory regions of Java program?

CuriousMind :

I haven't deep dive into how Java treats memory when a program is running as I have been in working at application level. I recently had one instance in which I needed to know owing to performance issues of application.

I have been aware of "stack" , "heap" regions of memory and I thought this is the model of a Java program. However, it turns out that it is much more, and beyond that.

For example, I came across terms like: Eden, s0, s1, Old memory and so on. I was never aware of these terminologies prior.

As Java is / have been changing and so may be these terminologies are/aren't relevant as of Java 8.

Can anyone guide where to get this information and under what circumstance we need to know them? Are these part of main memory that is RAM.

Joachim Sauer :

Java, as defined by the Java Language Specification and the Java Virtual Machine Specification talks about the stack and the heap (as well as the method area).

Those are the things that are needed to describe, conceptually, what makes a Java Virtual Machine.

If you wanted to implement a JVM you'd need to implement those in some way. They are just as valid in Java 13 as they were back in Java 1. Nothing has fundamentally changed about how those work.

The other terms you mentioned (as well as "old gen", "new gen", ...) are memory areas used in the implementation of specific garbage collection mechanisms, specifically those of implemented in the Oracle JDK / OpenJDK.

All of those areas are basically specific parts of the heap. The exact way the heap is split into those areas is up to the garbage collector to decide and knowing about them shouldn't be necessary unless you want to tweak your garbage collector.

Since garbage collectors change between releases and new garbage collector approaches are implemented regularly (as this is one of the primary ways to speed up JVMs), the concrete terms used here will change over the years.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=20772&siteId=1