Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

peculiar memory crash

Discussion in 'Scripting' started by joergipoergi, Mar 21, 2019.

  1. joergipoergi

    joergipoergi

    Joined:
    Aug 17, 2017
    Posts:
    16
    Hi
    I wanted to make a simple memory game, which worked fine, as long as i tested it on android. I have by now stripped down the application to this simple program:
    - I have ONE GameObject
    - The Gameobject has a script which has and exposes ONE variable. a public List
    - I have a bunch of PNGs, which should go in the gameobject.
    - That's it.
    If I drag more than about 30 of those PNGs (none larger than 100KB) to the List and test the app on iPad 1, or iPhone 5, it crashes right after launch.
    Reducing the images to less, there is no problem.
    How can I solve this?
    Is there an other way to load those images? Am I just doing something wrong? How can I run out of memory by making a list not larger then a couple MBs???
    Please, this is dricing me nuts.
     
  2. ThermalFusion

    ThermalFusion

    Joined:
    May 1, 2011
    Posts:
    906
    Compressed png file size does not matter. You can use the profiler to find out how much memory you're actually using.
    If you're loading your images yourself you may be loading them into uncompressed texture formats, these can get big very fast.
    Those vintage iDevices don't really have that much memory.
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Images don't exist in their original format in your build. So their compressed file size is irrelevant to the problem. Same goes for most any imported asset. iPhones are for some reason very memory limited. The iPhone 5 has only 1 GB of memory that you're sharing with everything else running on it.

    Even my wife's iPhone X has only 3 GB of memory for some reason, which is the same as my 5 year old Note 4 I just retired.
     
  4. joergipoergi

    joergipoergi

    Joined:
    Aug 17, 2017
    Posts:
    16
    Thanks for the replies.
    So what i did was the following.

    1) I load the images on demand from the Ressources folder.
    2) I reduced the size of the images.

    This still makes the iPad 1 crash sometimes, but compressing it, helped to make it run on the iPhone 5.

    I still can't believe though, that 3 MB of images could crash a phone with 1 GB RAM. What's happening there unity? Why do images bloat up the RAM so much??