Obi Official Forum
BurstColliderWorld.GenerateContactsJob Alloc - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html)
+--- Thread: BurstColliderWorld.GenerateContactsJob Alloc (/thread-2997.html)



BurstColliderWorld.GenerateContactsJob Alloc - ThoughtMango - 01-07-2021

Hi, 
Another day another random find when looking through unity's profiler, 
pre-allocating 32 elements in a NativeList removes a lot of alloc work inside the Job, like so (note, example is pretty extreme, 10s of simulations, but it's an 80% cut on standalone build)
[Image: prealloc.png]
Side Note: Value of 32 was chosen at random.


RE: BurstColliderWorld.GenerateContactsJob Alloc - josemendez - 01-07-2021

Thanks for sharing this! we don't preallocate in this case to keep baseline memory usage at a minimum (specially on mobile platforms), since the array is allocated for every particle, and many don't have any collisions during most frames. Haven't profiled it in detail though. Will try and find a good compromise between memory and performance, maybe 8 or 16 is good enough.


RE: BurstColliderWorld.GenerateContactsJob Alloc - ThoughtMango - 01-07-2021

Nps, glad to be of help. Every win counts, makes the wait for 7.0 a little easier too Lengua