#How do native containers behave (reference type / value type) ?

1 messages · Page 1 of 1 (latest)

misty obsidian
#

Hello
I'm starting to use DOTS and I think there is something I don't understand with native containers.
I see they are structs so I expected them to behave like value types but I feel like sometimes it is not the case.
When I pass a native container (NativeArray for example) to a method, what does the method receive? A copy of the array or the array itself? I thought it was a copy so I was using the array for other purposes after passing it to a function but I'm getting weird errors as if the array was a reference type and it was the same object in the function and outside of it (at least that's the only way I can understand the errors).
(For more context, I am giving an array to a job constructor that stores it and then uses it. Then I was disposing the array or modifying it after scheduling the job, thinking that the job only received a copy of it)

reef pendant
#

Generally:
NativeX - acts like reference type.
Under the hood it's a pointer to another pointer that points to actual allocated memory.
You treat it just like reference types.