Search Unity

Why does app uses more memory in iPad 2 than in iPad Air?

Discussion in 'iOS and tvOS' started by gecko, Jul 2, 2014.

  1. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    I've got an app that's pushing the limits of memory on iPad 2 -- it uses about 230mb, which is too much and I need to reduce it. However, when I put the same build on an iPad Air, uses 200mb of memory. I'd be a lot closer to my goal if iPad 2 used the same. Anybody know why? And is there any way to get the iPad 2 to use that lower amount?
     
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,653
    Are you running the same version of iOS on both devices ?
     
  3. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    Thanks for replying!

    Yes, that was with iOS 7 (whatever the final point release of 7 was) last summer. I've seen it now using 8.1 as well.

    The project itself is over 10gb; would submitting a but with the iOS build be at all helpful?
     
  4. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    844
    We had something like this a while ago on a project; it turned out our SD/HD texture loader was broken, and SD devices were loading HD art as well as SD art, whereas the HD devices were only loading HD art.

    Just a punt, but worth looking for something similar if you're doing selective loading.
     
  5. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    Thanks for the suggestion, Pix10. That's a good thing to watch out for....but we haven't added any HD graphics to the project yet.
     
  6. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    Doing more testing. I've got an iPad Mini 1 and an iPad Air, both with iOS 8.1.2. I built a single scene to iOS. On the Mini, xcode shows 238mb of memory usage. On iPad Air, 116mb. I've also tested on iPad 2 (albeit running 7.1.2) and it has 246mb memory.

    This is a simple scene with a fairly large city environment and a camera on an animation path. No game logic. So I can't imagine what would be causing this disparity. If only it were the other way, since the Air has plenty of memory... Anybody?
     
  7. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,653
    sorry for the late reply

    which version of Unity are you using ? would you be able to submit a bug report and post the bug# here ?
     
  8. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    I've seen this with Unity 4.5.1 and 4.5.4. But lately, I'm starting to think that it's simply xcode reporting the memory usage incorrectly. While running the game on iPad Air, I noticed (I think in Unity's profiler) that memory usage was closer to what iPad 2 showed in xcode. I was in the middle of testing something else, so just noticed this peripherally, but I *think* that the memory usage is the same, but xcode reports it incorrectly. I haven't had a chance to focus on that. WIll try to do so soon.
     
  9. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    844
    @gecko Did you ever get to the bottom of this? I'm actually seeing the same thing now myself - iPhone 4S and iPad 2 are clocking up 135MB where an iPad Mini Gen 2 and iPhone 6 sit at 114MB (this is with halfsize textures in quality settings on the iPad2/4S...never got to the bottom of if this makes a memory difference). Loading larger levels it goes up to 210MB on iPad 2 / 150MB on iPhone 6.

    I'm also half inclined to think it's XCode's reporting, as it seems a lot more stable standalone than when connected to Xcode or profiler. Bugger that we can't get memory stats in runtime.
     
  10. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    I haven't looked closer -- I think the thing to do is compare the Unity profiler's memory stats with xcode's, to see if they agree on those discrepancies.
     
  11. akeplinger

    akeplinger

    Joined:
    Oct 26, 2008
    Posts:
    45
    Seeing the same issue here. Xcode profiler reports that same app on iPhone 6 uses much less memory than on iPad 4th Gen. The iPad is retina, so I don't think it's from using HD +SD textures. Been having issues where using the home button and then going back to app it will restart on iPad but not on newer devices. Memory seems the likely cause. On iPhone 6 the app goes from 133MB down to 61Mb when returning from desktop. On iPad 4 the same app, not rebuilt, is using 209MB initially, and after switching to desktop and back the memory didn't go down. A huge difference in activity.
    Unclear what could be causing this from a development standpoint. iPhone 6 is running iOS 8.3. iPad 4 is running 8.2 Updating to 8.3 and will provide updated numbers. (Edit: no change after updating OS)
    It's behaving as if it doesn't want to properly clean up unused memory. As the game progresses it is calling System.GC.Collect() periodically. Doing this improved the memory on iPhone 6 but had no apparent effect on iPad 4.
    I can provide more information if anybody has ideas.
    First images below show apps carrying out same process from startup. Get to main menu, start a new game (Infinite runner), after a few seconds hit home button, return to game, play 5 seconds or so, hit home again, and resume. Top image is iPhone 6, bottom is iPad 4. memoryiP6.jpg memoryiP4.jpg
     
    Last edited: Apr 13, 2015
    MrEsquire likes this.
  12. Nakano37

    Nakano37

    Joined:
    Jan 13, 2011
    Posts:
    7
    I've seen this quite a bit as well and would love to know why. With our App, on the iPad2 it's typically around 180MB after login, but on iPad4 it usually is 150MB, and sometimes will drop way way down to like 50MB if you let it idle on the login page long enough. (both running the same build, both on iOS 8.3)

    While I have no concrete answer as to why this happens, my suspicion is that it's two-fold...

    First off, the GfxDriver memory seems larger on the iPad2.... about 64MB on the iPad2 vs 47MB on the iPad4...I'm not entirely sure what the "GfxDriver" memory is though, it seems to vary through the course of a run, so it's not just a static driver or something.

    Secondly, it seems like newer generation iPads are much smarter about how they swap memory that hasn't been accessed in a while out to disk.. the older iPad2's never seem to swap much out, while the iPad4s will push nearly everything out to disk if you aren't touching it.
     
  13. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    Still grappling with this -- and somehow, it's much worse now using 4.6.5 and xcode 6. Now iPad Air uses 150mb, and iPad 2/mini crashes when memory usage hits 250mb. Crazy!

    Also weird is that xcode reports much higher memory usage than does the Unity profiler. Should I assume the former is more accurate? EDIT: Turns out that Unity profiler and xcode agree about memory usage on iPad Air, but disagree on iPad 2/Mini. I'd be happy to ignore the latter disagreement, if only the game didn't crash.

    I've tried Metal, GLES3, GLES 2, and both Mono and IL2CPP -- no difference in memory usage or crashes. I guess I'll try to slim down the project and submit it with a bug report.
     
    Last edited: May 27, 2015
    MrEsquire likes this.
  14. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,852
    Could you please submit your project as bugreport for investigation?
     
  15. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    844
    Same here still, both iPhone 4S and iPad 2 are running >240MB, iPad Mini Gen 3, iPhone 6 ~134MB.

    I'm of a mind to think it's iOS rather than Unity, as the profiler doesn't show any real difference in allocations. The memory's being used, I'm sure of that, as the iPad 2 isn't very stable (yet iPhone 4S is, oddly). I'll submit the project when I get some breathing space.
     
    MrEsquire likes this.
  16. Hussam-Kazah

    Hussam-Kazah

    Joined:
    Oct 30, 2013
    Posts:
    2
    I am also facing the same problem.
    I have a 2D game with a very big map. A 10240 X 6144 that I have divided into 60 pieces each 1024x1024. On the iPhone 6, Xcode shows that the scene consumes 150 ~ 170 MB. On the other hand, the iPad 3rd Generation shows a consumption of 530+ MB. Both running iOS 8.3.
     
  17. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,852
    It would be interesting to look into your project too.
    Thanks!
     
  18. snusfen

    snusfen

    Joined:
    May 20, 2015
    Posts:
    43
    I have the same issue and came over this thread. Is there any further information on this issue or any idea what causes it?

    We're running Unity 4.6.3f1, XCode 6.1. Have tested on iPad3 (iOS 8.1.3), iPad2 (iOS 8.1.1), iPad Air (iOS 8.0). Building with IL2CPP, OpenGLES 2.0
    We use a lot of textures, and I get a roughly 100MB diff in lower memory usage on the Air compared to the iPad 2 and 3. Amusingly, running the game with Texture Quality set to quarter res in Quality Settings, I manage to reach about the same memory usage as the Air running full res.

    I can't submit this project, but if more data is needed I can try and see if I can reproduce the issue in a small test project.
     
    MrEsquire likes this.
  19. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    I made a simple repro project and submitted it. On iPad Mini 1, xcode shows memory usage at 50mb. On iPad Air, memory usage is 30mb. (Unity profiler shows memory at 36mb and 37mb, respectively, but I have heard that xcode is more reliable.) Case #710935.

    Also, I left the game running on my iPad Mini 1, and noticed after awhile that memory usage increased from 50mb to 57mb. I tried it again on iPad Air, and memory usage was stable.

    EDIT: BTW, this is on 4.6.5. Our project is stuck there until lightmapping tree shadows on terrain is working in 5.
     
    Last edited: Jul 9, 2015
  20. casperjeff

    casperjeff

    Joined:
    Apr 13, 2013
    Posts:
    333
    Any details you can give on your simple sample project? textures/sizes? animations? asset bundles? code/logic?
     
  21. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    It's very basic: A 1024x1024 terrain with 3-4 splats (no larger than 1024 each), and one type of tree painted across the terrain, and a directional light. No other code or logic.
     
  22. casperjeff

    casperjeff

    Joined:
    Apr 13, 2013
    Posts:
    333
    Any update/response on your submission (Case #710935)?
     
    MrEsquire likes this.
  23. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    Haven't heard anything yet.
     
  24. hunterua

    hunterua

    Joined:
    Nov 5, 2009
    Posts:
    41
    Same case for me.... same buid on iphone 6 is using much more less memory on main menu while same build running on ipad mini

    any news guys why it may happened ?
     
  25. frozenpepper

    frozenpepper

    Joined:
    Sep 17, 2007
    Posts:
    210
    same exact scene, view distance, quality settings etc and :

    Iphone 6 : 98 - 150mb reported by xCode
    iPad Air : 465 -540 mb (crashes often) reported by xCode
     
  26. super77gg

    super77gg

    Joined:
    Sep 25, 2014
    Posts:
    46
    we are experiencing similar issues. It seems to only be affecting older devices for us (iPad 2, iPod touch 5th Gen, iPad Mini 1)
     
  27. frozenpepper

    frozenpepper

    Joined:
    Sep 17, 2007
    Posts:
    210
    After further investigation, great part of the problem is due to the fact that iOs will not free unused memory until system requires memory. So in our case, iPhones had a ton of background applications opened, and system was very aggressive freeing up memory, while on test ipads that had few background applications opened system allowed application memory to grow way more before clearing it.
    You can verify if this is part of your problem, by opening a few safari tabs while your application is running, should see memory go down to expected values as system claims unused memory. (if you open too many tabs and apps while your unity app is in background it will be shut down)
     
    MrEsquire likes this.
  28. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    Hmm, that's interesting, @frozenpepper. So the iPad Air's memory readouts are accurate for iPad2 as well? But I get memory crashes on iPad 2 when the same app on iPad Air shows memory usage at 150-160mb, which should not cause a crash...
     
  29. knickerbocker

    knickerbocker

    Joined:
    May 8, 2014
    Posts:
    29
    Im getting the same exact problem. I get no crashes with the same app on an ipad air 2 but seemingly enough it crashes on an iphone 5s, xcode says it is a memory error. Can the unity team elaborate on this please?

    thanks
     
  30. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,852
    Hi Everyone,
    if you have projects that you could share to investigate this problem or maybe have apps in the App Store that could showcase the problem I would love to look into them.
    Thanks!
     
  31. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    @Mantas Puida : I submitted a simple repro project in early June, noted above. Case #710935.
     
  32. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,852
    I guess I missed it, thanks for pointing it out!
    P.S. other projects are still welcome!
     
  33. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    I just did an updated memory study of our game. I would run the game, load a single level, get the numbers, then quit the game, end its task, and then repeat with the next level. Unity 4.6.7p2, IL2CPP, Universal architecture, Graphics API automatic. Oh, and all of our textures are powers of 2, most of them are compressed using PVRTC (which should remain compressed even on the GPU).

    First the Unity Profiler, I added up Assets, Other, Not Saved and Scene Memory:
    iPad Air and iPad 4 (roughly the same on each device)
    Start Menu 156.5 MB
    Level 1 296.4 MB
    Level 2 292.3 MB
    Level 3 305.9 MB
    Level 4 339.1 MB

    Now Xcode Instruments using a VM Tracker snapshot, the *Dirty* row, Dirty Size column:
    IPad Air:
    Start Menu 161.54 MB
    Level 1 305.11 MB
    Level 2 267.31 MB
    Level 3 328.90 MB
    Level 4 312.59 MB

    iPad 4:
    Start Menu 290.05 MB
    Level 1 579.21 MB
    Level 2 548.78 MB
    Level 3 578.09 MB
    Level 4 605.11 MB

    Note, the iPad 4 is only used for testing, so the only app that is ever run on it is our Unity game. The iPad Air is a consumer device that gets a lot of use. Unfortunately, like I said in another thread, I'm not allowed to send our project, and even if I did it's 15GB.
     
    Last edited: Aug 26, 2015
    MrEsquire likes this.
  34. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,852
    Would it be possible get Xcode project / archive / ipa + DSYM files for local profiling?
     
  35. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    I'm sending the XCode build folder that Unity creates - still 3.5GB, but better than 15GB :) I'll post again when I have the bug number
     
  36. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,852
  37. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    Finally finished, it's Case # 722868
     
  38. ScrappyOrc

    ScrappyOrc

    Joined:
    Nov 25, 2013
    Posts:
    14
    I'm seeing a similar issue in 5.0.4f1. Running our game on iPad mini 1st gen we are seeing upwards of 270mb used, which is causing a crash, but in the same location in the game running on an iPad air (1st gen), we are only seeing 119 mb used. I measured memory usage using both the xCode profiler, and the Unity Profiler and saw similar results across both tools.
     
  39. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    Any update on this issue? Our biggest problem right now is memory crashes, and at this point it's mainly because of this bug, we've optimized our memory enough to fix major memory issues so to work around the problem any more we'd have to remove things (thus making our game worse).
     
  40. frozenpepper

    frozenpepper

    Joined:
    Sep 17, 2007
    Posts:
    210
    We have a very similar behaviour, odd thing is that in our case we receive memory warnings on iPad Air (and other modern devices too) when profiler and xCode are reporting only 160mb of memory use.
    Then we have our Jolly device, iPad Air 2 which reports constantly between 480 and 520 mb of memory in use (same build as others).
    Is anybody in this thread using asset bundles ?
     
  41. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    No asset bundles here
     
  42. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    Hate to be a pest, but any update on this? It's been over a year since the issue was first reported, it's still happening and easy to verify and we really need a fix.

    Something is making Unity take a significant amount of extra RAM on iOS devices compared to what the Unity Profiler says it should be using, except on 64-bit devices (even when not building for 64-bit or Metal/OpenGL 3).
     
  43. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    Is there any update on this horrible Unity bug?
     
  44. naughty

    naughty

    Joined:
    May 18, 2013
    Posts:
    1
    We've got this issue at the moment and one thing that hasn't been mentioned so far is that the platforms that use more memory seem to be 32bit platforms.
     
    MrEsquire likes this.
  45. fred_gds

    fred_gds

    Joined:
    Sep 20, 2012
    Posts:
    184
    Are there any updates on that issue? I also noticed it in previous projects and it would be great to know if that was solved.
     
  46. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    484
    Hi everyone,
    We've done some investigation into this issue with one of the Xcode projects provided. Our findings were that devices which are able to utilize Metal fared much better in terms of memory consumption. If you are able to switch to Metal, you may see improvements here. In terms of OpenGL on older devices, we did see a significantly larger portion of Dirty memory in the VM Tracker Instrument. We are still investigating this and will post any updates to this thread.
    Thanks.
     
    Last edited: Dec 10, 2015
  47. snusfen

    snusfen

    Joined:
    May 20, 2015
    Posts:
    43
    Thanks for following up on this!
     
  48. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    484
    After a little more digging, we discovered that memory consumption is directly related to which OpenGL backend the device is running. On the iPadAir with OpenGLES 2, we saw very similar memory consumption to the iPad 3 running OpenGLES 2. Memory consumption dropped modestly with OpenGLES3 on the iPad Air and then dropped significantly (compared to GLES 2) when using Metal.
     
  49. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    So GLES 2 is a memory hog and devices that are restricted to it will inevitably have higher memory use?
     
  50. christophergoy

    christophergoy

    Unity Technologies

    Joined:
    Sep 16, 2015
    Posts:
    484
    Yes, this is correct.
     
unityunity