FallbackAllocations in editor when using NativeStreams

Hello,

First of all, this is only happening in the editor! In builds all 3 streams are setup in 0.25ms.

I setup 3 NativeStreams with the same parameters and the first 2 take 0.25ms and the last one around 2ms.

After 2, fallback allocations are happening. Can we do something about it like increase the size before this is happening? Those allocations in editor are often tripping me up. :slight_smile:

int createAmount = 250000;
Profiler.BeginSample("Setting upstream1");
NativeStream stream1 = new NativeStream(createAmount, Allocator.TempJob);
Profiler.EndSample();

Profiler.BeginSample("Setting up stream2");
NativeStream stream2 = new NativeStream(createAmount, Allocator.TempJob);
Profiler.EndSample();

Profiler.BeginSample("Setting up stream3");
NativeStream stream3 = new NativeStream(createAmount, Allocator.TempJob);
Profiler.EndSample();

I think newer versions of Unity allow you to customize these allocator sizes. I don’t remember which versions nor which allocators.

Well, starting in Unity 2021.2 you can customize your allocator settings, and then there is Profiler.SetTempAllocatorRequestedSize.

2 Likes