Each thread uses its own fast stack allocator for temporary allocations. These allocations are very fast, with a lifespan of less than a frame. The allocator uses a last in, first out (LIFO) stack.
임시 할당자의 기본 블록 크기는 플랫폼의 경우 4MB이고 Unity 에디터의 경우 16MB입니다. 이 값은 커스터마이즈할 수 있습니다.
Note: If the allocator use exceeds the configured block size, Unity increases the block size. The limit for this increase is twice the original size.
If a thread’s stack allocator is full, allocations fall back to the threadsafe linear allocator. A few overflow allocations are fine: 1 to 10 in a frame, or a few hundred during load. However, if the numbers grow on every frame, you can increase the block sizes.
사용량 보고서의 정보는 애플리케이션에 적합한 블록 크기를 선택하는 데 도움이 될 수 있습니다. 예를 들어 다음 메인 스레드 사용량 보고서에서 로드는 2.7MB에서 최대이지만 나머지 프레임은 64KB 미만입니다. 블록 크기를 4MB에서 64KB로 줄이고 로딩 프레임이 할당을 초과하도록 허용할 수 있습니다.
[ALLOC_TEMP_TLS] TLS Allocator
StackAllocators :
[ALLOC_TEMP_MAIN]
Peak usage frame count: [16.0 KB-32.0 KB]: 802 frames, [32.0 KB-64.0 KB]: 424 frames, [2.0 MB-4.0 MB]: 1 frames
Initial Block Size 4.0 MB
Current Block Size 4.0 MB
Peak Allocated Bytes 2.7 MB
Overflow Count 0
[ALLOC_TEMP_Job.Worker 18]
이 두 번째 예에서 워커 스레드는 대량의 임시 할당에 사용되지 않습니다. 메모리를 절약하기 위해 워커의 블록 크기를 32KB로 줄일 수 있습니다. 이것은 각 워커 스레드에 자체 스택이 있는 멀티 코어 시스템에서 특히 유용합니다.
[ALLOC_TEMP_Job.Worker 14]
Initial Block Size 256.0 KB
Current Block Size 256.0 KB
Peak Allocated Bytes 18.6 KB
Overflow Count 0