๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
BackEnd๐ŸŒฑ/Java

[Java] JVM์˜ ๋ฉ”๋ชจ๋ฆฌ ๊ตฌ์„ฑ์š”์†Œ์™€ ์˜์—ญ์— ๊ด€ํ•œ ๊ณ ์ฐฐ

by dkswnkk 2022. 3. 18.

์„œ๋ก 

์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์ด ์‹คํ–‰๋˜๋ฉด, JVM์€ ์‹œ์Šคํ…œ์œผ๋กœ๋ถ€ํ„ฐ ํ”„๋กœ๊ทธ๋žจ์„ ์ˆ˜ํ–‰ํ•˜๋Š”๋ฐ ํ•„์š”ํ•œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ• ๋‹น๋ฐ›๊ณ  JVM์€ ์ด ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์šฉ๋„์— ๋”ฐ๋ผ ์—ฌ๋Ÿฌ ์˜์—ญ์œผ๋กœ ๋‚˜๋ˆ„์–ด ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€๋งŒ ์—ฌ๊ธฐ์„œ ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ์˜๋ฌธ์ด ์ƒ๊ฒผ์Šต๋‹ˆ๋‹ค. ์˜๋ฌธ์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  1. ์šฐ๋ฆฌ๊ฐ€ ํ”ํžˆ ์•„๋Š” ํ”„๋กœ์„ธ์Šค์˜ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์€ Heap, Stack, Data, Text ์˜์—ญ์œผ๋กœ ๋‚˜๋‰˜์–ด์ ธ์žˆ๋‹ค.
  2. JVM๋„ ํ•˜๋‚˜์˜ Process์ด๊ธฐ์— ์œ„์˜ ์˜์—ญ์„ ๋”ฐ๋ฅผ ๊ฒƒ์ด๋‹ค.
  3. ๊ทธ๋Ÿฌ๋‚˜ JVM์€ ๋˜ ๋‚ด๋ถ€์— Runtime Data Area๋ฅผ ๋‘์–ด 6๊ฐ€์ง€ ์˜์—ญ์œผ๋กœ ๋‚˜๋‰œ๋‹ค.
  4. ๊ทธ๋ ‡๋‹ค๋ฉด ํ”„๋กœ์„ธ์Šค ๋ฉ”๋ชจ๋ฆฌ์˜ ์–ด๋Š ์˜์—ญ์—์„œ JVM์˜ 6๊ฐ€์ง€ ์˜์—ญ๋“ค์ด ๋งŒ๋“ค์–ด์ง€๋Š” ๊ฒƒ์ผ๊นŒ?

์ •ํ™•ํžˆ ์•Œ๊ธฐ ์œ„ํ•ด์„œ ๋งŽ์€ ์„œ์นญ์„ ํ•˜์˜€์ง€๋งŒ ๋Œ€๋ถ€๋ถ„ JVM์˜ 6๊ฐ€์ง€ ์˜์—ญ์—๋งŒ ์„ค๋ช…ํ•˜์˜€๊ณ  ์ œ ๊ณ ๋ฏผ์„ ํ•ด๊ฒฐํ•ด์ค„ ๋ ˆํผ๋Ÿฐ์Šค๋ฅผ ์ฐพ๊ธฐ๋Š” ํž˜๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ œ๊ฐ€ ๋ช‡ ์•ˆ๋˜๊ฒŒ ์ฐพ์•„๋‚ธ ์ •๋ณด๋ฅผ ํ†ตํ•ด ๊ธ€์„ ์จ๋ณผ๊นŒ ํ•ฉ๋‹ˆ๋‹ค.

 

๋ณธ๋ก 

๋จผ์ € ์ฒซ ๋ฒˆ์งธ ์ฐธ๊ณ  ๊ธ€์ž…๋‹ˆ๋‹ค.  

 

JVM Memory segments allocation

Alright so I have a question regarding the Memory segments of a JVM, I know every JVM would choose to implement this a little bit different yet it is an overall concept that should remain the same

stackoverflow.com

 

ํ•ด๋‹น ๊ฒŒ์‹œ๊ธ€ ์ž‘์„ฑ์ž๋„ ์ €์™€ ๋˜‘๊ฐ™์ด  Code / Stack / Heap / Data ์˜์—ญ์œผ๋กœ ํ”„๋กœ์„ธ์Šค ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ๋‚˜๋ˆ„์–ด์ง€๋Š”๋ฐ JVM์€ Method area / Heap / Java Stacks / PC Registers / Native Stack ์™€ ๊ฐ™์€ ์˜์—ญ์œผ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์œผ๋‹ˆ ์œ„ JVM์˜์—ญ์€ ๋ˆ„๊ฐ€ ํ• ๋‹นํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š”์ง€ ๊ถ๊ธˆํ•ดํ•˜๋Š” ์งˆ๋ฌธ์ž…๋‹ˆ๋‹ค. 

๋‹ต๋ณ€์—์„œ ์ •ํ™•ํ•œ ๊ถ๊ธˆ์ฆ์€ ํ’€๋ฆฌ์ง€ ์•Š์•˜์ง€๋งŒ ๋ช‡ ๊ฐ€์ง€ ์‚ฌ์‹ค์„ ์•Œ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

  1. OS๋Š” ์‹คํ–‰ ์ค‘์ธ Java ํ”„๋กœ๊ทธ๋žจ์„ ์ธ์‹ํ•˜์ง€ ๋ชปํ•˜๊ณ  ์ปดํ“จํ„ฐ์—์„œ ์ผ๋ฐ˜ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ ์‹คํ–‰๋˜๋Š” JVM์˜ ์ผ๋ถ€๋ผ๊ณ  ์ƒ๊ฐํ•œ๋‹ค.
  2. Java์—์„œ์˜ ๊ฐ์ฒด ํ• ๋‹น์€ JVM์— ๊ด€๋ฆฌ๋˜๋ฉฐ, ์ด๋Ÿฌํ•œ ๊ฐ์ฒด ํ• ๋‹น์ด JVM์— ์˜ํ•ด ์ž‘๋™ํ•˜๋Š” ์œ ์ผํ•œ ์˜์—ญ์ด๋‹ค.
  3. JIT์ปดํŒŒ์ผ์€ ์ผ๋ฐ˜ OS ์Šค๋ ˆ๋“œ์—์„œ ๋ฐœ์ƒํ•˜๋ฉฐ ๊ฐ Java ์Šคํƒ์€ ์ผ๋ฐ˜ ์Šค๋ ˆ๋“œ ์Šคํƒ์ด๋‹ค.
  4. All other memory regions act just as they would in a C program, because the JVM is a C/C++ program.
  5. 4๋ฒˆ ์ฆ‰ JVM์ž์ฒด๋Š” C/C++ ํ”„๋กœ๊ทธ๋žจ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋‹ค๋ฅธ ๋ชจ๋“  ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์€ C ํ”„๋กœ๊ทธ๋žจ์—์„œ์™€ ๋™์ผํ•˜๊ฒŒ ์ž‘๋™ํ•œ๋‹ค.

์ •๋ฆฌํ•ด๋ณด๋ฉด JVM์˜ ์Šคํƒ ์˜์—ญ์€ ์ผ๋ฐ˜ ์Šค๋ ˆ๋“œ ์Šคํƒ์ž„์„ ์•Œ ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์˜ค์ง JVM์˜ Heap ์˜์—ญ๋งŒ์ด ํ”„๋กœ์„ธ์Šค์˜ Heap์˜์—ญ๊ณผ๋Š” ๋ณ„๊ฒŒ๋ผ๋Š” ์ ์„ ์•Œ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ์€ ๋‘ ๋ฒˆ์งธ ์ฐธ๊ณ  ๊ธ€์ž…๋‹ˆ๋‹ค.

 

Are JVM heap/stack different than virtual address space heap/stack?

Memory is divided into "segments" called heap, stack, bss, data, and text. However, the JVM also has these concepts of stack and heap. So how are these two reconciled? Are they different levels of

stackoverflow.com

 

ํ•ด๋‹น ์ž‘์„ฑ์ž๋„ ์ด์ „ ๊ธ€๊ณผ ์งˆ๋ฌธ์ด ๋น„์Šทํ•˜๊ธด ํ•˜์ง€๋งŒ ํ”„๋กœ์„ธ์Šค ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์˜ Heap, Stack๊ณผ JVM์˜ Stack ๋ฐ Heap์€ ์–ด๋–ค ๊ด€๊ณ„๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š”์ง€ ์งˆ๋ฌธํ•˜๋Š” ๊ธ€์ž…๋‹ˆ๋‹ค.

"This is only true for a typical user space process. In other word this will be true for an everyday program written in c or similar, however it is not true for all programs, and definitely not true for the entire memory space."

๋‹ต๋ณ€์€ ์œ„์™€ ๊ฐ™์€๋ฐ ์ผ๋ฐ˜์ ์œผ๋กœ ์šฐ๋ฆฌ๊ฐ€ ์•Œ๊ณ  ์žˆ๋Š” ํ”„๋กœ์„ธ์Šค์˜ ์˜์—ญ์ธ Heap, Stack, Data, Text๋ผ๋Š” ์˜์—ญ์€ ์ผ๋ฐ˜์ ์ธ ์‚ฌ์šฉ์ž ๊ณต๊ฐ„ ํ”„๋กœ์„ธ์Šค์—๋งŒ ํ•ด๋‹นํ•œ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰ C ๋˜๋Š” ์ด์™€ ์œ ์‚ฌํ•œ ์–ธ์–ด๋กœ ์ž‘์„ฑ๋œ ์ผ๋ฐ˜์ ์ธ ํ”„๋กœ๊ทธ๋žจ์—์„œ๋งŒ ์œ„์™€ ๊ฐ™์€ ์˜์—ญ์œผ๋กœ ๊ตฌ์„ฑ๋˜๊ณ  ๋ชจ๋“  ํ”„๋กœ๊ทธ๋žจ๋“ค์ด ์œ„์™€ ๊ฐ™์€ ์˜์—ญ์œผ๋กœ ์ ์šฉ๋œ๋‹ค๋Š” ์ ์€ ์•„๋‹ˆ๋ผ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

"When a program is executed the OS allocates memory for the various segments listed, except the the heap. The program can request memory from the OS while it is executing. This allows a program to use a different amount of memory depending on its needs."

ํ”„๋กœ๊ทธ๋žจ์ด ์‹คํ–‰๋  ๋•Œ๋Š” OS๋Š” ํž™์„ ์ œ์™ธํ•˜๊ณ  ๋‚˜์—ด๋œ ๋‹ค์–‘ํ•œ ์„ธ๊ทธ๋จผํŠธ์— ๋Œ€ํ•ด ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ• ๋‹นํ•ฉ๋‹ˆ๋‹ค. ํ”„๋กœ๊ทธ๋žจ์ด ์‹คํ–‰๋˜๋Š” ๋™์•ˆ OS์—์„œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์š”์ฒญํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ํ”„๋กœ๊ทธ๋žจ์€ ํ•„์š”์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ์–‘์˜ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

"Java allows program to request memory during execution using new. Memory allocated to a java program using new is referred to as memory in the java heap. One could imagine that if you where implementing a Jvm you would use malloc behind the scenes of new. This would result in a java heap within a regular native heap. In reality "serious" jvms do not do this and interact directly with the OS for memory."

Java๋Š” new๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์‹คํ–‰ํ•˜๋Š” ๋™์•ˆ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ํ• ๋‹น(์š”์ฒญ)ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋•Œ new๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด Java ํ”„๋กœ๊ทธ๋žจ์— ํ• ๋‹น๋œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ Java Heap memory๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰ ์ผ๋ฐ˜ ๊ธฐ๋ณธ Heap๊ณผ Java Heap์ด ๋”ฐ๋กœ ์žˆ๋‹ค๋Š” ๋ง์ž…๋‹ˆ๋‹ค. 

์ด์ œ ๋‹ต๋ณ€๋“ค์„ ์š”์•ฝํ•ด๋ณด์ž๋ฉด ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  1. ๊ผญ ๋ชจ๋“  ํ”„๋กœ๊ทธ๋žจ์˜ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์ด ์šฐ๋ฆฌ๊ฐ€ ํ”ํžˆ ์•Œ๊ณ  ์žˆ๋Š” 4๊ฐ€์ง€ ์˜์—ญ์œผ๋กœ ๋ฌด์กฐ๊ฑด์ ์œผ๋กœ ๋ถ„๋ฐฐ๋˜๋Š” ๊ฒƒ์€ ์•„๋‹ˆ๋‹ค.
  2. JVM ์ž์ฒด๋Š” C/C++ ํ”„๋กœ๊ทธ๋žจ์ด๊ธฐ ๋•Œ๋ฌธ์— ํž™์„ ์ œ์™ธํ•œ ๋‹ค๋ฅธ ๋ชจ๋“  ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์€ C ํ”„๋กœ๊ทธ๋žจ์—์„œ์™€ ๋™์ผํ•˜๊ฒŒ ์ž‘๋™ํ•œ๋‹ค.
  3. 2๋ฒˆ์—์„œ ์ด์ œ Heap ์˜์—ญ์ด Runtime Data Area๊ฐ€ ๋  ๊ฒƒ์ด๋‹ค.
  4. Java ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ํ•˜๊ฒŒ ๋˜๋ฉด Runtime Data Area์ด OS๋กœ๋ถ€ํ„ฐ JVM ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ ์•ˆ์˜ ๊ณต๊ฐ„์„ ํ• ๋‹น๋ฐ›๋Š”๋‹ค.
  5. ํ”„๋กœ์„ธ์Šค ํž™ ์•ˆ์—์„œ JVM ์˜ Runtime Data Area๊ฐ€ ํ• ๋‹น๋˜๋Š” ๊ฒƒ. 

๊ฒฐ๋ก : ๊ณ ๋กœ ๋‹ค์‹œ ๋Œ์•„์™€ ์ œ๊ฐ€ ๊ถ๊ธˆํ–ˆ๋˜ JVM์˜ 6๊ฐ€์ง€ ์˜์—ญ๋“ค์€ Runtime Data Area์•ˆ์— ์žˆ๊ณ , ์ด Runtime Data Area๋Š” ์•„๋ž˜์—์„œ ๋ณด๋ฉด ์•Œ๊ฒ ์ง€๋งŒ OS๊ฐ€ ํ•ด๋‹น ๋ฉ”๋ชจ๋ฆฌ์—๊ฒŒ ํ• ๋‹นํ•ด์คŒ(๊ทธ๋Ÿฌ๋‹ˆ ํ•ด๋‹น ํ”„๋กœ์„ธ์Šค์˜ Heap)์˜์—ญ, ๊ณ ๋กœ ํ”„๋กœ์„ธ์Šค์˜ Heap์˜์—ญ์•ˆ์— JVM์ด Runtime Data Area๋ฅผ ๋งŒ๋“ค์–ด 6๊ฐ€์ง€ ์˜์—ญ์œผ๋กœ ์ชผ๊ฐœ์–ด ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ž„์„ ์•Œ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. (๋ฌผ๋ก  GC ๊ฐ™์€ ๊ฒฝ์šฐ๋Š” JVM์˜ Heap์˜์—ญ๋งŒ ๊ด€๋ฆฌํ•œ๋‹ค.)

์œ„ ๋‚ด์šฉ๊นŒ์ง€๋Š” ํ™•์‹คํ•˜์ง€ ์•Š์œผ๋‹ˆ, ์ฝ์œผ์‹ค๋•Œ ์ด๋ฅผ ์ธ์ง€ํ•˜์‹œ๊ณ  ๋ณด์…จ์œผ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค.


๊ทธ๋Ÿผ ์ด์ œ JVM ๊ตฌ์„ฑ ์š”์†Œ์— ๋Œ€ํ•ด์„œ ํ•œ๋ฒˆ ์•Œ์•„๋ณด๋ฉด์„œ ์ดํ•ดํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

JVM ๊ตฌ์„ฑ ์š”์†Œ

JVM์˜ ๊ตฌ์„ฑ ์š”์†Œ๋Š” ์œ„ ์ด๋ฏธ์ง€์™€ ๊ฐ™์ด Class Loader, Execute Engine, ๊ทธ๋ฆฌ๊ณ  Runtime Data Area๋กœ ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค.

Class Loader javaํŒŒ์ผ → compile → .class(๋ฐ”์ดํŠธ ์ฝ”๋“œ) ํŒŒ์ผ ์ด๋ ‡๊ฒŒ ์ƒ์„ฑ๋œ .classํŒŒ์ผ๋“ค์„ ์—ฎ์–ด์„œ JVM์ด ์šด์˜์ฒด์ œ๋กœ๋ถ€ํ„ฐ ํ• ๋‹น๋ฐ›์€ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์ธ Runtime Data Area๋กœ ์ ์žฌํ•˜๋Š” ์—ญํ• ์„ ํ•œ๋‹ค.
Execute Engine ๋ฉ”๋ชจ๋ฆฌ์— ๋กœ๋“œ๋œ .class(๋ฐ”์ดํŠธ ์ฝ”๋“œ)ํŒŒ์ผ์„ ๊ธฐ๊ณ„์–ด๋กœ ๋ฒˆ์—ญํ•˜์—ฌ ์‹คํ–‰ํ•˜๋Š” ์˜์—ญ์„ ํ•œ๋‹ค.
Heap ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์— ์ƒ์„ฑ๋œ ๊ฐ์ฒด ์ค‘ Garbage Collector๋ฅผ ํ†ตํ•ด์„œ ๋ฉ”๋ชจ๋ฆฌ ๊ด€๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค.
Runtime Data Area OS์—์„œ ํ•ด๋‹น ํ”„๋กœ์„ธ์Šค์—๊ฒŒ ํ• ๋‹นํ•ด์ฃผ๋Š” ๋ฉ”๋ชจ๋ฆฌ๋ฅผ JVM์ด ์šฉ๋„์— ๋งž๊ฒŒ ๋ถ„ํ• ํ•ด์„œ ์‚ฌ์šฉํ•œ๋‹ค.

์—ฌ๊ธฐ์„œ Runtime Data Area๋ฅผ ์ข€ ์ž์„ธํžˆ ์•Œ์•„๊ฐˆ ํ•„์š”๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์˜์—ญ์€ JVM ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์œผ๋กœ์จ, OS๋กœ๋ถ€ํ„ฐ ๋ณ„๋„์˜ ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„์„ ํ• ๋‹น๋ฐ›๊ณ  ์ž๋ฐ” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์‹คํ–‰ํ•  ๋•Œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ํฌ๊ฒŒ 5๊ฐ€์ง€ ์˜์—ญ์œผ๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

JVM์˜ Runtime Data Areas

  1. Method Area: ๋ชจ๋“  ์Šค๋ ˆ๋“œ๊ฐ€ ๊ณต์œ ํ•˜๋Š” ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์ด๋‹ค. Method Area๋Š” class, interface, Method, field, static ๋ณ€์ˆ˜ ๋“ฑ ๋ฐ”์ดํฌ ์ฝ”๋“œ ๋“ฑ์„ ๋ณด๊ด€ํ•œ๋‹ค. (๊ณต์œ ์ž์›)
  2. Heap: ํ”„๋กœ๊ทธ๋žจ ์ƒ์—์„œ ๋Ÿฐํƒ€์ž„ ์‹œ ๋™์ ์œผ๋กœ ํ• ๋‹นํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋Š” ์˜์—ญ์ด๋‹ค. class๋ฅผ ์ด์šฉํ•ด instance๋ฅผ ์ƒ์„ฑํ•˜๋ฉด Heap์— ์ €์žฅ๋œ๋‹ค. (๊ณต์œ  ์ž์›)
  3. Stack Area: ๋ชจ๋“  ์Šค๋ ˆ๋“œ์— ๋Œ€ํ•ด ๋ณ„๋„์˜ ๋Ÿฐํƒ€์ž„ ์Šคํƒ์ด ๋งŒ๋“ค์–ด์ง„๋‹ค. ์Šคํƒ ์˜์—ญ์€ ๊ณต์œ  ์ž์›์ด ์•„๋‹ˆ๋ฏ€๋กœ ์Šค๋ ˆ๋“œ ์•ˆ์ „ ์˜์—ญ์ด๋‹ค. (๊ณต์œ  ์ž์› X)
  4. PC Register: ์Šค๋ ˆ๋“œ๊ฐ€ ์ƒ์„ฑ๋  ๋•Œ๋งˆ๋‹ค ์ƒ์„ฑ๋˜๋Š” ์˜์—ญ์œผ๋กœ Program Counter, ์ฆ‰ ํ˜„์žฌ ์Šค๋ ˆ๋“œ๊ฐ€ ์‹คํ–‰๋˜๋Š” ๋ถ€๋ถ„์˜ ์ฃผ์†Œ์™€ ๋ช…๋ น์–ด๋ฅผ ์ €์žฅํ•˜๊ณ  ์žˆ๋Š” ์˜์—ญ์ด๋‹ค.(CPU ๋ ˆ์ง€์Šคํ„ฐ์™€ ๋‹ค๋ฅด๋‹ค, ๊ณต์œ  ์ž์› X)
  5. Native Method Stack: ์ž๋ฐ” ์™ธ ์–ธ์–ด๋กœ ์ž‘์„ฑ๋œ ๋„ค์ดํ‹ฐ๋ธŒ ์ฝ”๋“œ๋ฅผ ์œ„ํ•œ ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์ด๋‹ค. ๋ณดํ†ต C/C++ ๋“ฑ์˜ ์ฝ”๋“œ๋ฅผ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•œ ์Šคํƒ์ด๋‹ค. Native Method Library์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜๊ณ  Execution Engine์— ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ œ๊ณตํ•œ๋‹ค. (๊ณต์œ  ์ž์› X)

 

๋งˆ์น˜๋ฉฐ..

JVM ๊ตฌ์„ฑ์š”์†Œ์— ๊ด€ํ•ด์„œ๋Š” ์›Œ๋‚™ ์ •๋ณด๊ฐ€ ๋งŽ๊ธฐ์— ์ •ํ™•ํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•˜์ง€๋งŒ, ๋ณธ๋ฌธ ์ ค ์ฒ˜์Œ์˜ ์˜๋ฌธ์— ๋Œ€ํ•œ ๋‹ต์€ ์ œ๊ฐ€ ๋ฐœ ๋ฒˆ์—ญ์„ ํ•ด๊ฐ€๋ฉฐ ์ดํ•ดํ•œ ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ์ •ํ™•ํ•˜์ง€ ์•Š์„ ํ™•๋ฅ ์ด ๋†’์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๋ฌด์กฐ๊ฑด ์ ์œผ๋กœ ๋งž๋‹ค๊ณ  ์ƒ๊ฐํ•˜์ง€ ๋งˆ์‹œ๊ณ  ํ˜น์‹œ ์ •ํ™•ํ•œ ์ •๋ณด๋ฅผ ์•Œ๊ณ  ๊ณ„์‹œ๋Š” ๋ถ„์€ ๋Œ“๊ธ€ ์ข€ ๋‚จ๊ฒจ์ฃผ์…จ์œผ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค..

๋Œ“๊ธ€