Mesh Taking Up More Memory Than Expected

I’m using the advanced mesh API to create procedural generated terrain, and while profiling my code, I noticed that the Mesh objects, according to the profile take up 45.4MB even though the inspect says that the mesh only accounts for 13.0MB for the vertices (position + normal) and 2.2MB for the indices.

I looked at other threads and one of them suggests using the Mesh.UploadMeshData() method, but (I’m guessing here) since I’m using the advanced mesh API, there is no data to upload to the GPU. That’s why when I use that method, I don’t see any improvement in memory usage.

What could be causing the discrepancy between the two measurements? I’m on Unity version 2021.2.7f1.

do you set Mesh.UploadMeshData(true), if so this should free up all the memory and only use gpu memory , otherwise there is a bug , quite possible as well cause I use the same api and am encountering a memory issue myself

Yep, I did Mesh.UploadMeshData(true), and it didn’t reduce the memory usage (which makes sense since all of the mesh data is already on the GPU).

This sounds like you might’ve hit this bug which was fixed and backported to 2021.2.8f1. Could you please check if updating fixes this?

Yep that seemed to do the trick thanks!

1 Like