Hi,
I’m currently using AsyncGPUReadback.RequestIntoNativeArray(ref array, …) to asynchronously read the data of a RenderTexture I’m blitting to every few frames. I’m using a NativeArray in an effort to reduce recurring garbage allocations. So far so good. I got everything to work like I want it to, but it seems like I’m still doing something wrong with the NativeArray I’m passing to the method.
I’m allocating a NativeArray with Allocator.Persistent, pass that to RequestIntoNativeArray() and use that NativeArray to do some other stuff after the AsyncGPUReadbackRequest has completed. When quitting the game I try to clean up after myself and call Dispose() on the persistent array.
Sometime the following problem occurs:
When I stop my application in the Editor the following exception is thrown:
“InvalidOpertationException: [NativeArray…] has been set to undisposable and cannot be deallocated”
And when I hit Play again after that:
“A Native Collection has not been disposed, resulting in a memory leak. Allocated from: …”
Both exceptions point to the array I mentioned above. This seems somewhat contradictory to me.
Does anyone have a clue as to what the issue is, if there is any?