Table of Contents
public void ShowMemoryStatus()
{
Debug.Log("Total Reserved memory by Unity: " + ((Profiler.GetTotalReservedMemoryLong() / 1024f) / 1024f) + "MB");
Debug.Log("- Allocated memory by Unity: " + ((Profiler.GetTotalAllocatedMemoryLong() / 1024f) / 1024f) + "MB");
Debug.Log("- Reserved but not allocated: " + ((Profiler.GetTotalUnusedReservedMemoryLong() / 1024f) / 1024f) + "MB");
Debug.Log("- Mono used size" + ((Profiler.GetMonoUsedSizeLong() / 1024f) / 1024f) + "MB");
}
- Bytes로 출력하고 싶다면
/1024f
두개를 빼면 된다 - KB로 출력하고 싶다면 한개만 빼면 된다
출처
Unity - Scripting API: Profiling.Profiler.GetTotalReservedMemoryLong
This function returns the total memory Unity has reserved for current and future allocations. If the reserved memory is fully used, Unity will allocate more memory from the system as required.
docs.unity3d.com
Unity - Scripting API: Profiling.Profiler.GetMonoUsedSizeLong
This function returns the amount of allocated managed-memory for all objects, both live and non-collected. Always call GC.Collect before calling this function, because non-referenced objects still take up space until the garbage collector (GC) collects the
docs.unity3d.com
'Unity > C#' 카테고리의 다른 글
[Unity] JsonUtility.ToJson() 대신 Jobject.FromObject()를 쓰자 (1) | 2024.06.17 |
---|---|
[Unity] Unity 3D Game Kit Lite템플릿 Damageable스크립트 분석 (1) | 2024.05.22 |
[C#] DateTime에서 남은시간 계산하기 (0) | 2023.02.25 |
[Unity] Builder패턴으로 팝업 시스템 구현 (0) | 2023.02.16 |
[Unity] GoogleSheetsToUnity에셋 활용 동적 스크립터블 오브젝트 생성기 제작 (0) | 2022.10.25 |