01-12-2023, 08:05 AM
(This post was last modified: 01-12-2023, 08:13 AM by josemendez.)
(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,