Search Unity

Feedback Job system Manual Allocator.Temp needs revising

Discussion in 'C# Job System' started by TheOtherMonarch, Nov 8, 2021.

  1. TheOtherMonarch

    TheOtherMonarch

    Joined:
    Jul 28, 2012
    Posts:
    866
    Everything I have read on this forum is that Allocator.Temp is always a No-op and just creates useless overhead. The job system Manual seems to say otherwise. Is it only a No-op with Burst? I think the documentation should be revised.
     
  2. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    792
    In all honesty, I've never heard Allocator.Temp create overhead. Did I miss something? The only thing I've heard is that Temp is the fastest allocation type, and my guess is that a preallocated linear allocator is used here, in which the pointer is reset every frame and Dispose() is ignored.
     
  3. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    529
    I think @TheOtherMonarch is talking only about the Dispose call not being required and generating overhead.
    Afaik not disposing Temp memory doesn't produce actual leaks but eg allocations in a loop sum up whereas they do not when Disposing them.
     
  4. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    Based off this thread,
    https://forum.unity.com/threads/allocator-temp-container-need-dispose.852082/#post-5619760
    I thought dispose on Temp was a no-op

    s_schoener
    Freeing Temp memory is a no-op. For jobs, it is automatically released once the job finishes. It is still a good idea to not allocate temp memory for every single iteration of an IJobParallelFor since you can exhaust the Temp allocator.

    s_schoener
    No, there is no need to dispose them. It's a no-op.
     
  5. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    Dispose of Temp memory is a no-op on the native side.
    It's just wrong documentation which will be fixed.