> For the complete documentation index, see [llms.txt](https://incheol-jung.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://incheol-jung.gitbook.io/docs/study/with-scouter/chap-14..md).

# CHAP 14. 잘라 놓은 메모리 단면 분석하기

## scouter를 사용하여 메모리 문제 진단하기

scouter를 이용하여 메모리의 상태를 모니터링할 수 있는 그래프는 다양하다. 메뉴에서 Collector → Tomcat(혹은 Java)을 선택한 상태에서 메모리와 관련된 메뉴들은 다음과 같다.

### GC 관련

* GC Time : 특정 시간 동안 총 GC를 수행하는 데 소요된 시간
* GC Count : 특정 시간 동안 총 GC를 수행한 횟수

### 힙 관련

* Heap Used : 각 JVM에서 사용한 힙 메모리의 크기
* Heap Memory : 각 JVM에 할당된 힙 메모리의 크기와 사용한 힙 메모리의 크기

참고로 자바 8 이상을 사용할 경우 permanent 영역은 존재하지 않기 때문에 관련 그래프를 볼 필요는 없다. 만약 메모리 릭이 발생한다면

* GC Time은 급격히 증가하고
* GC Count도 급격히 증가하며
* Heap Memory 그래프는 할당된 부분 근처에서 지속해서 요동을 치며 올라갔다 내려갔다를 반복할 것이다.

### 기본적인 습관을 가지자

어떤 서버를 새로 모니터링한다면, 이 메모리 사용 현황과 GC를 수행하는 데 소요되는 시간 등을 모니터링하는 것은 가장 먼저 해야 하는 작업 중 하나다. GC가 얼마나 소요되는지, 메모리가 부족한 상황인지를 확인하지 않으면, 어느 순간 장애가 발생했을 때 메모리가 큰 걸림돌이 될 수 있기 때문에 기본적으로 확인하는 습관을 가져야만 한다.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://incheol-jung.gitbook.io/docs/study/with-scouter/chap-14..md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
