✅ Method 영역(Perm Gen)은 Non-heap 영역이다
JVM 구조에 대해 한번이라도 공부해 봤던 사람이라면 알겠지만.. Perm Gen 영역은 보통 Heap 영역에 포함된 상태로 그려져 있다. 그런데 Perm Gen 영역과 Heap을 동일 취급하지 않고 구분해서 설명한다. 또 Method 영역은 Perm Gen 영역에 포함되어 있다고 하지 Heap 영역에 속해있다고 하지 않는다. 결론은 뭘까?
일반적으로 메서드 영역은 힙(Heap) 영역의 일부로 간주된다고 나오지만, 오라클 공식 문서를 보면 Method 영역을 Non-heap 영역으로 구분한다는 것을 찾아볼 수 있다.
위 다이어그램은 JVM의 메모리 튜닝 인자를 설명하고 있는데 메모리 튜닝 인자 관점에서 볼 때 Perm Gen은 힙 영역의 일부가 아니라는 것을 확실하게 확인할 수 있다.
또, 힙 공간이 고갈되면 아래와 같은 메세지를 받지만
java.lang.OutOfMemoryError: Heap space space
Perm Gen 영역이 고갈되면 다른 에러 메세지를 받는다.
java.lang.OutOfMemoryError: PermGen space
그렇다면 왜 오라클의 공식문서에는 아래의 다이어그램이 그려져 있을까?
이는 JVM 메모리 개념을 '세대(generation)' 관점에서 설명하기 위해 그려진 것으로 추정된다고 한다.
Permgen is part of heap or not?
I have found picture from official oracle site but in popular SO answer I have found that permanent generation is not part of heap Permanent Generation (non-heap): The pool containing all the
stackoverflow.com
🤔 Permanent Generation은 GC 대상이야?
메서드 영역은 명시적으로 가비지 컬렉션을 선택하지 않는 단순한 구현에서는 가비지 컬렉션이 실행되지 않을 수 있다. 메서드 영역에는 클래스의 메타데이터와 코드 등이 저장되는데, 이러한 정보들은 일반적으로 애플리케이션이 실행되는 동안 변경되지 않기 때문에 가비지 수집이 필요하지 않다. 대신, 메모리 부족 상황(OutOfMemoryError)이나 클래스 로딩 및 언로딩 등의 이유로 JVM은 메서드 영역을 관리한다.
메모리 부족 상황이 발생하면 가비지 컬렉션의 대상이 되는 것은 힙(Heap) 영역이다. 힙 영역은 객체 인스턴스와 배열 등이 저장되는 공간이며, Full GC가 발생하여 메모리를 회수할 때 메타데이터가 Method 영역에 저장되어 있는 경우에 영향을 받을 수 있다.
따라서 Perm Gen(이제는 Metaspace)에 클래스 메타데이터가 너무 많이 쌓이면 Heap에 여유 공간이 많더라도 Full GC가 발생할 수 있는 것이다. 이는 클래스 로딩 및 메타데이터 저장에 따른 문제로, 메소드 영역(Metaspace)에서의 가비지 컬렉션과는 별개의 문제이다.
Java Garbage Collection Basics
Java Overview Java is a programming language and computing platform first released by Sun Microsystems in 1995. It is the underlying technology that powers Java programs including utilities, games, and business applications. Java runs on more than 850 mill
www.oracle.com
Permgen is part of heap or not?
I have found picture from official oracle site but in popular SO answer I have found that permanent generation is not part of heap Permanent Generation (non-heap): The pool containing all the
stackoverflow.com
In Java is Permanent Generation space garbage collected?
I have read that Perm gen (or Permanent Generation) space is not garbage collected. However, in CMS collection I can see some classes unloading in my GC log. So is perm gen garbage collected during...
stackoverflow.com
Will the loaded class in 'method area' be unloaded by GC?
In hotspot jvm , in memory area there are heap and method area , and in method ,there are 'heap' and 'method area' etc. The object I new is set to heap, the classes, field , interface loaded by
stackoverflow.com
What Java Garbage Collectors cleanup PermGen?
List of Garbage Collectors: Serial GC Parallel GC Parallel Old GC Conc Mark Sweep GC G1 GC I know that the Conc Mark Sweep GC supports cleaning up PermGen when you enable the ClassUnloading JVM
stackoverflow.com
Dealing with "java.lang.OutOfMemoryError: PermGen space" error
Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It's a typical Hibernate/JPA + IceFaces/JSF application running on Tomcat 6 and JDK 1.6. Apparently
stackoverflow.com
Is the permanent generation always collected serially on the HotSpot VM?
From reading a rather mature Oracle blog entry, I learned that (...) the permanent generation is currently collected serially. However, this blog entry is from quite some years ago and I was
stackoverflow.com
'Study' 카테고리의 다른 글
[오픈소스] Spring Boot 프로젝트 컨트리뷰터 되기 (0) | 2024.04.29 |
---|---|
[Java] 자바 런타임 데이터 영역(Runtime Data Area) (0) | 2024.02.19 |
[Java] 변수와 객체 데이터 저장 (0) | 2024.02.17 |
[DB] 트랜잭션의 격리 수준(Isolation Level)이란? (0) | 2024.02.16 |
[Java] 객체비교 시 equals()와 hashcode() 둘 다 재정의해야 하는 이유 (0) | 2024.02.13 |