Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  [FIXED] Dispose of atomic safety handle error when game start
#7
(01-12-2023, 07:50 AM)kaser Wrote: Hello, I have tried the solution the error was disappear but...
This approach may cause memory leak issues.

When False, the possible cause of memory leak is that the AtomicSafetyHandle.Release was not executed correctly

As long as the list's constructor is called, isCreated will be true and the safety handle will exist.

Only in cases where the constructor hasn't been called or Dispose() has been already called, isCreated will be false. This prevents double deallocations of the safety handle and attempting to deallocate it when it doesn't exist.

Typically, Obi's own code always calls the constructor of the list, so even with the original code there are no cases where a null safety handle is destroyed if the list has been properly created. However, seems like newer Unity versions can create an instance of the list during serialization without calling its constructor, but will call Dispose() when destroying it nonetheless. Making sure that the safety handle is only destroyed if the list has had its constructor called is the correct thing to do.

Also note that safety handles are only ever used when the editor's safety system is enabled, and are skipped entirely in builds.

kind regards,
Reply


Messages In This Thread
RE: Dispose of atomic safety handle error when game start - by josemendez - 01-12-2023, 08:05 AM