동적 힙 할당자는 메인 힙 할당자입니다. TLSF(2단계 분리 맞춤) 알고리즘을 메모리 블록에 적용합니다.
각 플랫폼에는 커스터마이즈할 수 있는 기본 블록 크기가 있습니다. 할당은 블록의 절반보다 작아야 합니다. 할당 크기가 블록의 절반 이상인 경우 동적 힙 할당자에게 너무 크기 때문에 Unity는 대신 가상 메모리 API를 사용하여 할당합니다.
동적 힙 할당자에 대한 메모리 사용량 보고서의 예는 다음과 같습니다.
[ALLOC_DEFAULT_MAIN]
Peak usage frame count: [16.0 MB-32.0 MB]: 497 frames, [32.0 MB-64.0 MB]: 1 frames
Requested Block Size 16.0 MB
Peak Block count 2
Peak Allocated memory 54.2 MB
Peak Large allocation bytes 40.2 MB
이 예에서 TLSF 블록 크기는 16MB로 설정되고 Unity는 두 개의 블록을 할당했습니다. 할당자의 최대 사용량은 54.2MB였습니다. 52.4MB 중 40.2MB는 TLSF 블록에 할당되지 않고 가상 메모리로 대체되었습니다. 대부분의 프레임에는 16–32MB의 메모리가 할당된 반면 한 프레임(로딩 프레임으로 추정)은 최대 32–64MB의 메모리를 사용했습니다.
블록 크기를 늘리면 큰 할당이 가상 메모리로 대체되지 않고 동적 힙에 유지됩니다. 그러나 블록 크기가 크면 블록이 완전히 사용되지 않을 수 있으므로 메모리 낭비로 이어질 수 있습니다.
팁: 타입 트리 및 파일 캐시 할당자는 동적 힙 할당을 사용합니다. 이 알고리즘에서 사용할 메모리 블록을 줄이려면 타입 트리 블록 크기와 파일 캐시 블록 크기를 0으로 설정하면 됩니다. 그러면 타입 트리와 캐시를 사용하던 할당이 대신 메인 할당자에게 폴백됩니다. 참고 이 경우 네이티브 메모리 단편화가 증가할 위험이 있습니다. 이러한 블록 크기를 설정하는 방법은 할당자 커스터마이즈를 참조하십시오.
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.