Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

iOS optimization issues w/ screen shots

Discussion in 'Editor & General Support' started by nution, Dec 16, 2013.

  1. nution

    nution

    Joined:
    Nov 7, 2012
    Posts:
    10
    So, Ive been struggling with an iOS game where I have a fairly decent sized level, but overall nothing extravagant or unheard of. Ive optimized the living hell out of every possible thing I can think of, but to no avail. When I build the game to xcode, there are just constant memory warnings firing off. Most of the time, when I test it, it crashes out due to "memory pressure" on the device. This is on a 4s. If I use my iPad mini, its the same result, probably being that the hardware for these two devices is basically identical. If I use my iPad, (think its an iPad2) everything is fine, and runs / looks great. Probably because the iPad2 has 1gb of ram where the phone and mini have 500mb. However, my game isn't approaching these high ram levels.
    My build size fluctuates from 120-165mb out of unity, however after install, its almost always around 220mb, no matter what the build size was, being high or low, it always ends up running around 220mb on the phone. On the iPad, its closer to the 250-260mb range, off the same build oddly enough. Ive attached some screen shots of the build data and Xcodes debug profiler. What is even more strange is, if the app loads on the phone, and stabilizes after about 3-5 seconds, then its fine. It will run 25-30fps with no issue and I can run all over the place with not even a glitch. Any insight on how to use more of the phones ram instead of hitting this invisible wall, or anyone having similar experiences with his, I would love to hear your thoughts.
    $Screen Shot 2013-12-15 at 9.06.21 PM.png
    $Screen Shot 2013-12-15 at 9.06.45 PM.png
    $Screen Shot 2013-12-15 at 9.07.06 PM.png
    $Screen Shot 2013-12-15 at 9.11.20 PM.png
     
  2. WheresMommy

    WheresMommy

    Joined:
    Oct 4, 2012
    Posts:
    890
    Hey there,

    did you check all of your textures for being compressed right? Do you Switch a lot of textures or load lots of Images like a "Video" ? These are just some issues I have been running through. Are you using a Atlas for your UI? Some more Details would be great about your assets :)
     
  3. nution

    nution

    Joined:
    Nov 7, 2012
    Posts:
    10
    The UI isnt very evolved as of now, but yes it is using an atlas. I've made sure all the compression settings are optimal for mobile (and tried about every method on the list to see if I could find a hidden gem), everything in the scene is using mostly just 4 major atlases, then some small atlases and few small (kb) textures for things like particle effects or that use a shader not common to a material elsewhere. I converted the terrain into a mesh (didn't really effect anything + or -), using occlusion culling (the built in one), very small amount of light mapping (totals 8mb over 4 files), real time lighting is done by one directional light in the scene, all other lights are turned off after baking, turning this still activated light off has no effect.

    I don't think texture switching is my issue, mostly because the atlases I'm using for the materials of the scene are so inclusive of many objects scattered around the scene that I don't think they would be jumping in and out very often, if at all. Like I said when the game is actually loaded, it runs pretty smooth, its the getting it to start that's the issue. If you look at that first image I posted, it says there is 291.8mb "free". During loading, there were "other processes" using memory but loading this kills them all off and drops the added ram into this "free" pool. As you see it in these images, it is on the cusp of failure. Very close to crashing and barely able to load. When it fails, it says "Terminated due to memory pressure".
     
    Last edited: Dec 16, 2013
  4. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    your cpu is pretty high too, do you use something like destroy instanciate for your gameobject?
     
  5. nution

    nution

    Joined:
    Nov 7, 2012
    Posts:
    10
    Right now there is nothing being generated into the scene. It is a static level completely. No game objects are being instantiated as of now.
     
  6. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    try

    https://github.com/handcircus/Unity-Resource-Checker

    - haven't checked it since 3.5 but it should still work. That helped us nail tonnes of ram issues in TOB we didn't know existed. Build output size very much isn't in relation to how much ram you're using in a scene. Usual culprits which will screw things up for you are sounds and textures - these don't really relate to how much actual ram they'll use in game.

    The invisible wall which quits your app is iOS springboard. It will have spammed the xcode console with memory warnings before then, as you're obviously not allowed to use all the device ram. Shooting for half the device ram is generally OK though.

    If you get a memory warning level = 2 at any point it means it will most likely crash on end user's devices at some point.
     
    Last edited: Dec 16, 2013
  7. nution

    nution

    Joined:
    Nov 7, 2012
    Posts:
    10
    Thanks for that tip on Resource Checker. Makes narrowing down the big boy assets much easier. Sadly though what Im seeing in the report is what Ive been digging through for almost a week now with not any real room to optimize them individually. An interesting find would be why apps are terminating when not even using half the ram of the device. Whats kind of even more odd, on android, no issue with crashing, however the game runs much slower. iOS stays pretty solid in its frame rate in mid to high 20's. Android is all over the place from 17-20's down to 4-7 in places with lots of detail. My android though has a slightly faster cpu and twice the ram.
     
  8. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    your screenshots show you are in the danger zone for that device, and it is warning your console. You need to simply keep chopping until it fits or it will not be stable. Every iPhone and OS has different thresholds. Specially with the new iOS7 taking up more ram than ever. Something has to be sacrificed. Have you tried 16 bit? or even 24 bit (if it helps?) Going to have to get a bit creative and chop something. Try different audio lengths, or streaming the music.

    If it's Unity pro it will also save some ram with build stripping I believe.
     
  9. Saddamjit_Singh

    Saddamjit_Singh

    Joined:
    Dec 4, 2015
    Posts:
    22
    Same problem here.

    Getting memory warning on iOS and then getting message "Terminated because of memory issue" and game crashes.

    Any way out?
     
  10. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    well which version of Unity are you using, this thread is 3 years old!
     
  11. Saddamjit_Singh

    Saddamjit_Singh

    Joined:
    Dec 4, 2015
    Posts:
    22
    Sir i am using 5.1.0 and 5.2.3 .
     
  12. Saddamjit_Singh

    Saddamjit_Singh

    Joined:
    Dec 4, 2015
    Posts:
    22
    Many thanks for your reply sir.

    Sir unity memory profiler is not helping me.
    My game works well for first 3-4 minutes on iPhone and after that it starts becoming heavy slowly and slowly with every scene load. Xcode starts showing memory warnings and finally it crashes.

    My game is 2D and there are many animations and textures and 52 scenes in my project.

    I have used System.GC.Collect,Optimisation of code,marking GameObjects static,Resources.UnloadUnusedAssests,decreasing size of textures etc but still memory issue is coming.

    I have also introduced an empty scene between scene loading and used Resources.Load to load heavy textures in all scenes but still no success.

    I really need to fix this error as soon as possible sir.

    Any help sir?
     
  13. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Maybe you should make abackup of your project and test with latest version of Unity, reason no one is replying is because with the information you have provided we do not understand the cause of the issue.

    Plus stop spamming the forums with the copy and paste.
    So dont expect reply after this.