I've only tested for this on Android. When we delete a tabletop map gameobject, the native heap memory usage and graphics memory usage doesn't go back to zero (the level before the map was initialized). I've tried to manually destroy the rendertextures, materials, meshes, and textures in the GPUResourceProvider before deleting the map and tried deleted the rendertexture related to terrain occlusion in the ArcGISRenderer script but I either still get the memory leak or the app crashes, likely because of some improper destroy function I'm running in my manual code. I want to know what the best way is to remove an ArcGIS map from a unity scene without causing a memory leak. Its clear that just deleting the map gameobject doesn't help. The render textures, meshes etc for the map that are cached don't seem to be destroyed during garbage collection.
Hi there,
I can take a look into this. I believe the only time we have ever tried destroying a map and all of its accompanying game objects is when physically switching scenes. With that said, we haven't tried it with our table top sample. I'll take a look at this today and get back to you asap.
Mason
Much thanks @MasonGaw . Please let me know what you find.
I took a look into this. I am curious what you need to clone the tabletop map for, however looking at your code you are using the Prefab in the scene for cloning and deleting. This is not allowed in unity since once you delete the one in scene it will lose it's reference and no longer know what to spawn/delete. Additionally, Destroying the original will not get rid off all copies of the tabletop map in scene. You have a for loop commented out, this is correct way to destroy all copies of it.
However to solve the problem of the Memory Leak, I did not see one. What I think is happening is when you spawn in extra table top maps, it is not actually spawning into the scene and the memory being used that you are not seeing be freed up is actual the initial memory from starting the scene and everything loading in. When I spawned in extra table top maps, I did not see any get rendered. I could be wrong, but I believe spawning in extra maps is either not possible using this method, or not possible at this time. I hope this helps.
Mason Gaw