Using Instruments or Xcode, my iOS game uses around 115 MB memory when the menu scene is loaded. After doing battles and other things within the game and reloading the menu, the memory usage is up to 170 MB.

The real problem is that Unity's profiler doesn't tell me anything: there are a few MB of extra system libraries and a few MB of extra Texture2D assets, but there's no explanation for the big increase. Adding more Resources.UnloadUnusedAssets() and GC.Collect() doesn't help.

How can I investigate this? (Note: it reaches a steady state. The memory doesn't continue to rise after a certain point.)

  • \$\begingroup\$ 170MB consistent or just a peak? \$\endgroup\$ – Hamza Hasan Feb 18 '16 at 11:31
  • \$\begingroup\$ @HamzaHasan It's fairly steady, fluctuating by 0.5 MB or so. \$\endgroup\$ – piojo Feb 18 '16 at 11:33
  • \$\begingroup\$ Well, I don't know your situation, but for that what I did is add the loading screen between the scenes so in the meanwhile unity discards all the previous allocations... \$\endgroup\$ – Hamza Hasan Feb 18 '16 at 11:35
  • \$\begingroup\$ @HamzaHasan Thanks. I just tested that and it doesn't help. Even loading a nearly-empty scene doesn't get rid of the phantom memory. \$\endgroup\$ – piojo Feb 18 '16 at 12:04
  • \$\begingroup\$ give it some delay, and load scene in async mode (from loading scene). Means call Loading scene immediately, then give some delay and then load next scene in async mode.. This is what I did \$\endgroup\$ – Hamza Hasan Feb 18 '16 at 12:08

valgrind could help you detect memory leaks. I think there is an OSX version.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.