https://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html
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
๊ฐ๋น์ง ์ปฌ๋ ์ (Garbage Collection, GC)
- ์๋ฐ์์ ๋ฉ๋ชจ๋ฆฌ ๊ด๋ฆฌ๋ฅผ ์๋์ผ๋ก ์ํํ๋ ๊ธฐ๋ฅ
- Garbage Collector ์ฌ์ฉํ์ฌ ๋ถํ์ํ ๊ฐ์ฒด๋ฅผ ์๋์ผ๋ก ๋ฉ๋ชจ๋ฆฌ์์ ์ ๊ฑฐ
์ฃผ์ ๊ฐ๋
- ๊ฐ์ฒด์ ์ฐธ์กฐ
- ์๋ฐ์์ ๊ฐ์ฒด๋ Heap ๋ฉ๋ชจ๋ฆฌ์ ์์ฑ๋จ
- ๋ ์ด์ ์ฌ์ฉํ์ง ์๋ ๊ฐ์ฒด๋ ๋ฉ๋ชจ๋ฆฌ์์ ์ ๊ฑฐ
- ๊ฐ์ฒด๊ฐ ์ฐธ์กฐ๋๋ ๊ฒฝ์ฐ๋ Garbage Collector๊ฐ ์ญ์ ํ์ง ์๋๋ค
- Garbage Collection์ ๋์ ์๋ฆฌ
- ์ฐธ์กฐ ์นด์ดํธ : ๊ฐ ๊ฐ์ฒด๊ฐ ๋ช๊ฐ์ ์ฐธ์กฐ๋ฅผ ๊ฐ์ง๊ณ ์๋์ง ๊ณ์ฐ
- mark-sweep ์๊ณ ๋ฆฌ์ฆ : ์ด์์๋ ๊ฐ์ฒด๋ฅผ ๋งํฌํ ํ ๊ทธ ์ธ์ ๊ฐ์ฒด๋ฅผ ์ค์ํ์ฌ ์ญ์ ํจ
- mark-compact ์๊ณ ๋ฆฌ์ฆ : mark-sweep์ ๋จ์ ์ธ ๋ฉ๋ชจ๋ฆฌ ๋จํธํ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ๋งํฌํ ํ ์ด์์๋ ๊ฐ์ฒด๋ฅผ ์ฐ์๋ ๊ณต๊ฐ์ผ๋ก ์ด๋
- GC์ ์ข ๋ฅ
- Young Generation : ์๋ก ์์ฑ๋ ๊ฐ์ฒด๋ค์ด ์ ์ฅ๋๋ ์์ญ
- Old Generation : ์ค๋๋ ๊ฐ์ฒด๋ค์ด ์ ์ฅ๋๋ ์์ญ
- Permanent Generation / Metaspace : ํด๋์ค ๋ฉํ๋ฐ์ดํฐ์ ๊ฐ์ ์ ๋ณด๋ฅผ ์ ์ฅ
- GC์ ์ฃผ๊ธฐ
- Minor GC : Young Generation์์ ๋ฐ์ํ๋ Garbage Collection์ผ๋ก, ์์ฃผ ๋น ๋ฅด๊ฒ ๋ฐ์
- Major GC : Old Generation์์ ๋ฐ์ํ๋ Garbage Collection์ผ๋ก, ์๋์ ์ผ๋ก ์ ๊ณ ์ค๋์๊ฐ์ ๊ฑธ์ณ ๋ฐ์
- GC ์๊ณ ๋ฆฌ์ฆ
- Serial GC : ๋จ์ผ Thread๋ก Garbage Collection ์ํ, ์์ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ ํฉ
- Parallel GC : ์ฌ๋ฌ Thread๋ฅผ ์ฌ์ฉํ์ฌ Garbage Collection ์ํ, ๋ฉํฐ ์ฝ์ด ์์คํ ์์ ์ฑ๋ฅ ํฅ์
- Concurrent Mark-Sweep (CMS) GC : ์ ํ๋ฆฌ์ผ์ด์ ๊ณผ ๋์์ Garbage Collection์ ์ํํ์ฌ ์๋ต์ฑ ํฅ์
- G1(Garbage-First) GC : ๋ํ Heap์์ ํจ์จ์ ์ธ Garbage Collection์ ๋ชฉํ๋ก ์ค๊ณ๋ GC
Garbage Collection์ ์ฅ์ ๊ณผ ๋จ์
- ์ฅ์
๋ฉ๋ชจ๋ฆฌ ๊ด๋ฆฌ๊ฐ ์๋์ผ๋ก ๋จ
๋ฉ๋ชจ๋ฆฌ ๋์ ๊ฐ๋ฅ์ฑ ์ค์ด๋ฆ
- ๋จ์
GC๊ฐ ์ํ๋๋๋์ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฑ๋ฅ์ด ์ ํ๋ ์ ์์
์ค์๊ฐ ์์คํ ์์๋ GC๊ฐ ์ฑ๋ฅ์ ๋ณด์ฅํ๊ธฐ ์ด๋ ค์
'Java' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JAVA] Wrapper Class (0) | 2022.01.14 |
---|---|
[JAVA] ์ฑ๊ธํค ํจํด์ด๋? (0) | 2022.01.11 |
[JAVA] ํ๋ก์ธ์ค(Process)์ ์ค๋ ๋(Thread) (0) | 2022.01.11 |
[JAVA] ์ ์ถ๋ ฅ(I/O) ๋ณด์กฐ ์คํธ๋ฆผ : BufferedReader, BufferedWriter (0) | 2022.01.11 |
[JAVA] ์ ๊ทผ์ ์ด์ (public, protected, default, private) (0) | 2022.01.11 |