Hi, Is the function Profiler.GetTotalFragmentationInfo() safe to call in a Release build game every few seconds to gather info? The documentation for the other memory-related calls say that values of 0 are returned in Release mode but not the documentation for GetTotalFragmentationInfo.
We’re on 2022.3.21f1.
The Profiler.GetTotalFragmentationInfo
method scans Unity’s general purpose native memory allocator walking through relatively large (1-4MB) memory regions to get native fragmentation information. It is relatively fast, but it may be also dangerous to call as we use it primarily in Memory Profiler when we stop all allocations. I would avoid using it in final builds tbh
2 Likes
To add to that and in case there is any doubt left there: “Unity’s general purpose native memory allocator” here means that yes, this has absolutely nothing to do with managed/scripting heap fragmentation.
(Adding this here because there’s often confusion around native allocator customization and it’s effect on managed heap fragmentation and similarly, there is none)
1 Like