When meshes are loaded ?

Hello, i am newbie in Unity !

I’m developing an app for iOS loaded with a lot of textures, and do not quite understand how to read data profiler. I need to optimize memory management because when running the app on the device lasts a few seconds and crashes.

A particular question I have is if all meshes are always instantiated or at which point they are loaded ?. Because in the profiler I see all meshes instanced and occupying memory, even running an empty scene.

When meshes are loaded ?
They should not be loaded with the GameObject ?
Maybe they are detected from a non-visible scene. Could it be ?

Thanks.

Meshes are loaded into memory when:

  1. You load scene - everything referenced by it is loaded (including mesh references and prefabs with meshes on them).

  2. When you call Resource.Load/AssetBundle.LoadAsset - you get reference to mesh/prefab containing mesh, that’s now loaded in memory.

  3. When you manually create Mesh.

  4. When you’re using MeshFilter.mesh (instead of MeshFilter.sharedMesh when it was used to set up mesh). It’ll create a copy if it’s not using an exclusive copy already.

  5. When you instantiate object with its MeshFilter using .mesh instead of .sharedMesh. It duplicates Mesh.

P.S. It’s also possible they’re still loaded in editor from your previous non-empty scene. They will then be shown in profiler. In my case profiler’s amount of Meshes loaded in empty scene dropped a lot when I restarted Unity.