Making an endless racing game. Memory usage is around 120 MB on iOS and android when I start race. But this number keep growing over time. Not clearly able to point the problem with the help of profiler.
After I play for about half an hour memory usage is around 350 MB. Then even if I change the scene (game to menu scene) memory number around 300 MB. What could be the reason.
If I am instantiating, but not destroying, the effect of memory increment should be within the scene.
You should be object pooling. It will save a lot of processing power and is practically mandatory for larger games.
Here’s a Unity tutorial that will give a nice run-down an demonstration of how it works.
Cheers! -PlayWell Studios
Just use the in built oculusion culling or create a box around the player so when anything touches it it will automatically delete it self
Not quite sure why the memory usage is staying high after you switch back to the menu scene, but whatever the case, pooling is the way to go. You can reuse alot of objects like projectiles, particle effects, trees, street models, collectables etc. I helps you keep your memory consumption stable.
I recently wrote an article about this topic. Maybe it helps you finding a solution to your problem: Pooling Part 1: Optimize your game’s performance – Christian Henschel