bumdream / morning_study

1 stars 0 forks source link

JVM 메모리 구조에서 힙 #9

Open tituvely opened 6 years ago

tituvely commented 6 years ago

This area is created at the time of JVM startup and is destroyed when the JVM stops. The heap is shared among all the threads of execution.
힙 영역은 JVM이 시작할 때 생성되고 멈추면 소멸된다. 실행시간 동안 모든 스레드가 공유하는 영역.

Space for objects created by new operator

힙은 어디에 사용되나

The heap contains a lot of other data areas in general which we will explain in detail in the sections below.
힙은 여기저기 많이 사용됩니다.

The memory for class instances or arrays is allocated from the heap. Which means, the moment a thread executes a statement like int[] X = new int[10], a memory block to store this array is allocated from the heap. A JVM implementation may have an automated storage management system (we know it as the garbage collector). The block of memory which is allocated for the objects and arrays can be de-allocated by the storage management system when it is appropriate (here appropriate is a complex term and needs a separate discussion).

클래스 인스턴스나 어레이를 위한 메모리는 힙에 할당된다. ex) int[] X = new int[10] JVM은 garbage collector를 갖고 있어서 자동으로 메모리 관리를 해줍니다. 그래서 힙 영역에 할당된 메모리들은 적당한 시점에 자동으로 해제됩니다.

Method Area is logically a part of the heap. Hence, the heap must provide space for method area. Method Area is shared among all threads of execution. The method area stores the per class structures, for e.g.: field and method data, the run time constant pool, code for method and constructors and special initialization methods like or

메소드 영역은 논리적으로는 힙영역. 그래서 힙이 메소드 영역에 대한 공간도 제공해줘야 합니다. 메소드 에리어도 실행시간 중 모든 스레드에 공유됨. 앗 여기는 제 파트가 아닌것 같습니다.

Run-time Constant Pool is logically a part of the method area and it is a per class or per interface representation of the constant_pool table in a class file. It is created when the class or interface is created. It contains constants like numeric literals and string literals known at compile time, for e.g.: String s = “techieme.in” or int k = 10. It also contains field of method references which must be resolved at the run time.

힙과 관련된 에러 컨디션

As we said about the stack, the heap can also be of fixed or dynamic size. If any computation requires more heap than can be made available by the automatic storage management, then it will throw a OutOfMemoryError.

힙은 고정된 크기일수도 있고 동적인 크기일 수도 있다. 만약 힙 영역보다 더 큰 공간을 요구하는 계산이 있다면, OOutOfMemoryError가 납니다.

The same error can occur if it is not able to create the method area or run time constant pool.