The code used for disposal is a simple
private void OnDestroy()
{
triangulationData.Dispose();
}
Not sure if the error is there, or if i didnt allocate it properly
It was allocated with
NativeArray triangulationData;
triangulationData = new NativeArray(cell.roads, Allocator.Persistent);
ot sure when i went wrong, had a look on google and unity answers and couldnt see anything about this issue
If you’re seeing an error when calling nativeCollection.Dispose();
it’s because Dispose()
was called for this allocation already and possibly somewhere completely elsewhere.
_
As this is a race condition issue, to fix it, make sure this array has only one clearly defined owner who’s job is to deallocate it and nobody else is. If your class isn’t the owner of this allocation - don’t dispose it. Only then this error will go away.
_