Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BurstColliderWorld.GenerateContactsJob Alloc
#1
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.
Reply
#2
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.
Reply
#3
Nps, glad to be of help. Every win counts, makes the wait for 7.0 a little easier too Lengua
Reply