Search Issue Tracker
Fixed in 2019.1.X
Votes
0
Found in
Issue ID
932011
Regression
No
[Scripting, Profiler] It's not possible to get runtime size for meshes
With the current APIs Unity provides, it is difficult to determine exactly where the memory footprint for a mesh is coming from, especially during runtime. Get internal memory during runtime in release mode is not possible which leads to estimates which is difficult without knowing the correct format which depends on many different factors. During profiling it's possible, but you will always get the profiler overhead. e.g. via Profiler.GetRuntimeMemorySize (mesh);
For Meshes there is already a call used by the profiler Mesh::GetRuntimeMemorySize() which consists of 2 parts which only return related memory in dev mode, otherwise zero.
- Profiler.GetRuntimeMemorySize (mesh); Includes base memory footprint for C++ objects as well as the base class.
- SharedMeshRenderingData::GetRuntimeMemorySize() returns the index buffer size + the vertex streams included.
So in theory we can enable the second part during runtime as it doesn’t require the profiler. This requires additionally scripting bindings. See the attached diff for the implementation. This returns the size the mesh occupies via mesh.GetRuntimeMemorySize ().
TestStuff.cs tests the call against other API calls in
Debug.Log("GetRuntimeMemorySize: "+mf.mesh.GetRuntimeMemorySize ());
Build the test scene in non development mode to iOS/Android and test on device.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- “Default Scene” dropdown field contains a spelling mistake “Default Builtin”
- Editor crashes on PPtr<Mesh> after adding Text Mesh and Cloth Components to the same GameObject
- Previously deleted “DefaultLookDevProfile“ is present when upgrading the Editor version
- [Ubuntu] UI text and buttons are missing spaces in Unity Version Control > New Workspace window
- "Inherit attribute is not supported" warning is shown but attributes are available in VFX Graph Output and Update blocks
Add comment