Company
교육 철학

Profiler Information

Profiler Information

관련 소스 파일
Scripts/Runtime/Debugger/DebuggerComponent.GraphicsInformationWindow.cs
Scripts/Runtime/Debugger/DebuggerComponent.ProfilerInformationWindow.cs
Scripts/Runtime/Debugger/DebuggerComponent.SceneInformationWindow.cs
Scripts/Runtime/FileSystem/AndroidFileSystemStream.cs

Introduction

Profiler Information 기능은 Unity Game Framework의 디버깅 툴킷의 일부로, 실시간 메모리 사용량과 성능 지표를 제공합니다.
이 툴은 개발자가 게임 플레이 중 리소스 소비를 모니터링할 수 있게 하여, 메모리 누수 확인, 성능 문제 추적, 게임 애플리케이션 최적화에 필수적입니다.
일반적인 디버깅 도구에 대한 내용은 Debugger Component 페이지를 참고하세요.

Architecture

Profiler Information 창은 DebuggerComponent 내의 ProfilerInformationWindow 클래스로 구현되어 있습니다.
이 클래스는 ScrollableDebuggerWindowBase 를 상속하여, 표시할 정보가 화면을 넘어설 경우 스크롤 가능한 UI를 제공합니다.

Implementation Details

ProfilerInformationWindow는 Unity의 Profiler API 에 직접 접근하여 메모리 및 성능 지표를 가져옵니다.
핵심 기능은 OnDrawScrollableWindow() 메서드에 있으며, Unity의 IMGUI 시스템을 사용해 프로파일링 정보를 출력합니다.

Profiler Metrics

ProfilerInformationWindow는 프로파일러 상태 정보와 메모리 사용 정보를 표시합니다.
카테고리
지표
코드 엔티티
설명
Status
Supported
Profiler.supported
현재 플랫폼에서 프로파일링 지원 여부
Enabled
Profiler.enabled
프로파일링이 활성화되어 있는지 여부
Enable Binary Log
Profiler.enableBinaryLog
바이너리 로그 활성화 여부 및 로그 파일 경로
Enable Allocation Callstacks
Profiler.enableAllocationCallstacks
할당 콜스택 활성화 여부 (Unity 2019.3+)
Area Count
Profiler.areaCount
프로파일러 영역 개수 (Unity 2018.3+)
Max Used Memory
Profiler.maxUsedMemory
사용된 최대 메모리 (Unity 2018.3+)
Memory
Mono Used Size
Profiler.GetMonoUsedSizeLong()
Mono 런타임이 사용 중인 메모리
Mono Heap Size
Profiler.GetMonoHeapSizeLong()
Mono 런타임 힙의 총 크기
Used Heap Size
Profiler.usedHeapSizeLong
현재 사용 중인 힙 메모리
Total Allocated Memory
Profiler.GetTotalAllocatedMemoryLong()
총 할당된 메모리
Total Reserved Memory
Profiler.GetTotalReservedMemoryLong()
총 예약된 메모리
Total Unused Reserved Memory
Profiler.GetTotalUnusedReservedMemoryLong()
예약되었으나 사용되지 않은 메모리
Allocated Memory For Graphics Driver
Profiler.GetAllocatedMemoryForGraphicsDriver()
그래픽 드라이버에 할당된 메모리 (Unity 2018.1+)
Temp Allocator Size
Profiler.GetTempAllocatorSize()
임시 할당자 크기 (Unity 5.5+)
Marshal Cached HGlobal Size
Utility.Marshal.CachedHGlobalSize
캐시된 HGlobal 메모리 크기
코드에서는 #if 전처리 지시문을 사용하여 Unity 버전별 호환성을 유지합니다.
#if UNITY_2019_3_OR_NEWER DrawItem("Enable Allocation Callstacks", Profiler.enableAllocationCallstacks.ToString()); #endif
C#
복사

Platform Considerations

Unity 버전에 따라 지원되는 프로파일링 지표가 다릅니다.
ProfilerInformationWindow 클래스는 전처리 지시문을 통해 이러한 차이를 처리하여 모든 지원 Unity 버전에서 올바르게 동작합니다.
예시:
Unity 2019.3+ : 할당 콜스택 정보 제공
Unity 2018.3+ : 영역 개수, 최대 사용 메모리 제공
Unity 2018.1+ : 그래픽 드라이버 메모리 제공
Unity 5.5+ : 임시 할당자 크기 제공
따라서 표시되는 지표는 Unity 버전에 따라 달라집니다.

Using the Profiler Information Window

사용 방법:
1.
씬에 DebuggerComponent 가 부착된 GameObject가 있어야 합니다.
2.
실행 중에 디버그 키(일반적으로 ~ 키)를 눌러 디버거를 엽니다.
3.
디버거 인터페이스에서 Profiler Information 패널을 선택합니다.
4.
게임 플레이 도중 실시간으로 메트릭을 모니터링합니다.

Optimization Use Cases

Profiler Information 창은 다음과 같은 상황에서 성능 문제를 파악하는 데 유용합니다:
메모리 누수 탐지: "Total Allocated Memory" 값이 계속 증가하고 해제되지 않는 경우 확인
관리 코드 최적화: "Mono Used Size" 또는 "Mono Heap Size"가 크다면 과도한 GC나 비효율적 관리 코드 사용 가능성
그래픽 메모리 사용량 추적: "Allocated Memory For Graphics Driver" 값으로 텍스처, 메시, 렌더 타겟의 GPU 메모리 사용량 확인
메모리 단편화 확인: "Total Reserved Memory" 와 "Total Unused Reserved Memory" 비교로 단편화 여부 파악

Related Debugging Tools

게임 성능을 종합적으로 분석하려면 Profiler Information 창과 함께 다음 툴도 활용하세요:
Graphics Information Window : 그래픽 디바이스, 기능, 렌더링 설정 상세 정보 제공
Scene Information Window : 현재 씬의 오브젝트 개수 및 씬 메트릭 제공
Runtime Memory Information Window : 시스템별 메모리 사용 상세 내역 제공
Console Window : 로그, 경고, 에러 표시 → 특정 이벤트와 성능 문제 연관성 확인