참고: 이 섹션의 할당자에 대한 정보는 네이티브 메모리에만 적용되고 관리되는 힙에는 적용되지 않으며, 이에 대한 내용은 관리되는 메모리 섹션에서 다루고 있습니다. 이 섹션에서는 네이티브 메모리 관리 및 할당자에 대한 일반적인 이해를 갖춘 것으로 가정합니다.
애플리케이션은 메모리 할당자를 사용하여 성능과 사용 가능한 메모리 공간의 균형을 유지합니다. 여유 메모리가 많은 애플리케이션은 씬과 프레임을 로드할 때 메모리 소모가 많더라도 더 빠른 할당자를 선호합니다. 그러나 애플리케이션에 제한된 메모리가 있는 경우 느린 할당자를 사용하더라도 해당 메모리를 효율적으로 사용해야 합니다. 다양한 프로젝트에서 최고의 성능을 얻을 수 있도록 Unity의 할당자를 각 애플리케이션의 크기와 요구 사항에 맞게 커스터마이즈할 수 있습니다.
Unity에는 5가지의 할당자 타입이 있습니다. 각 타입은 메모리 블록에 할당을 맞추는 알고리즘이 다르므로 각자 다른 할당에 유용합니다. 할당 간의 중요한 차이점은 대개 지속성이나 할당 수명으로, 이는 할당이 어디로 가야 하는지를 결정합니다. 예를 들어 수명이 긴(지속성) 할당은 힙 및 버킷 할당자로 이동하며, 수명이 짧은 할당은 스레드세이프 리니어 및 TLS 할당자로 이동합니다.
다음 표에는 각 할당자 타입의 알고리즘과 용도가 나와 있습니다.
할당자 타입 | 알고리즘 | 용도 |
---|---|---|
동적 힙 | 2단계 분리 맞춤(TLSF) | • 메인 할당자 • Gfx 할당자 • 타입트리 할당자 • 파일 캐시 할당자 • 프로파일러 할당자 • 에디터 프로파일러 할당자(에디터 전용) |
버킷 | 고정된 크기의 무잠금 할당자 | 작은 할당을 위한 공유 할당자로 사용 • 메인 할당자 • Gfx 할당자 • 타입트리 할당자 • 파일 캐시 할당자 |
듀얼 스레드 | 크기와 스레드 ID를 기반으로 할당을 리디렉션합니다. | • 메인 할당자 • Gfx 할당자 • 타입트리 할당자 • 파일 캐시 할당자 |
TLS(스레드 로컬 스토리지) 스택 | LIFO 스택 | 임시 할당 |
스레드세이프 리니어 | 라운드 로빈(Round robin) FIFO | 잡에 데이터를 전달하기 위한 버퍼 |
참고:
-log-memory-performance-stats
커맨드 라인 인자를 사용한 경우, 이 문서의 예시에서는 플레이어나 에디터를 닫을 때 로그에 기록되는 메모리 사용량 보고서를 사용합니다. 로그 파일을 찾으려면 로그 파일 페이지의 지침을 따르십시오.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.