Search Unity

When a system executes, do all of the lambda jobs execute or only the ones with satisfied queries?

Discussion in 'Entity Component System' started by Abbrew, May 14, 2020.

  1. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    The specific problem is that I have 2 ForEach lambdas that use a native container which must be deallocated. Both ForEach use a different query. I'm not sure if I should put WithDeallocateOnJobCompletion on the later or both ForEachs. If one executes but the other one doesn't then a memory leak would occur
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    If no RequireForUpdate things involved, thus this ForEach queries will work as a logic OR, thus if both empty (without filtering) system wouldn't run. If any of them has entities - the system will run, but empty ForEach - not. Just replace WithDeallocateOnJobCompletion to
    container.Dispose(Dependency)
     
    Abbrew likes this.