How to make sure I don't allocate too much memory for NativeArrays? (to prevent crash)

do I have to explictly make sure that some limit isn’t exceeded, or will the Unity engine make sure that the game doens’t crash if the Player allocates too much memory?

How is it set up?
If you don’t know the size, maybe use lists?

No because that would crash either way I suppose. :wink:
How much is “too much”? It depends on the system. A 4 GB vs a 64 GB system for instance. So what’s your target hardware? If it has to run on a 4 GB machine it’s your responsibility to ensure it is working on that.

You can monitor some of the Memory Profiler counters in Release builds using ProfilerRecorders to check what your current memory usage is before making your allocations.

1 Like