Search Unity

Issue with too much ram occupation on ios devices

Discussion in 'Web' started by r8zbeh, May 3, 2020.

  1. r8zbeh

    r8zbeh

    Joined:
    Dec 4, 2018
    Posts:
    40
    I created a blank scene without any script and removed all packages, then i added a box with a material assigned to containing four 10mb textures(resolution: 4k -compression: normal) , then i made a Webgl1 build with brotli compression with .wasm format. (build size:28 mb)
    An ios device with 1GB ram stuck on 90% while loading (which means there's not enough allocated ram!)
    while memory allocation limit on this device is 645mb.
    how is it possible that such a small project decompressed and heap size exceed 645 megabytes ?!



    this is the Editor log :
    Code (log):
    1. Build Report
    2. Uncompressed usage by category (Percentages based on user generated assets only):
    3. Textures               42.7 mb     75.9%
    4. Meshes                 0.0 kb     0.0%
    5. Animations             0.0 kb     0.0%
    6. Sounds                 0.0 kb     0.0%
    7. Shaders                151.9 kb     0.3%
    8. Other Assets           5.7 kb     0.0%
    9. Levels                 10.5 kb     0.0%
    10. Scripts                270.5 kb     0.5%
    11. Included DLLs          13.2 mb     23.3%
    12. File headers           8.0 kb     0.0%
    13. Total User Assets      56.3 mb     100.0%
    14. Complete build size    85.4 mb
    15. Used Assets and files from the Resources folder, sorted by uncompressed size:
    16. 10.7 mb     12.3% Assets/test size/4.jpg
    17. 10.7 mb     12.3% Assets/test size/3.jpg
    18. 10.7 mb     12.3% Assets/test size/2.jpg
    19. 10.7 mb     12.3% Assets/test size/1.jpg
    20. 153.2 kb     0.2% Resources/unity_builtin_extra
    21. 0.9 kb     Assets/test size/New Material.mat
    22. 4.1 kb     0.0% C:/Program Files/Unity 2019.1.4f1/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll
    23. 4.1 kb     0.0% C:/Program Files/Unity 2019.1.4f1/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/Standalone/UnityEngine.UI.dll
    24. 0.9 kb     0.0% C:/Program Files/Unity 2019.1.4f1/Unity/Editor/Data/UnityExtensions/Unity/TestRunner/UnityEngine.TestRunner.dll
    25.  
     
  2. OceanX000

    OceanX000

    Joined:
    Feb 24, 2021
    Posts:
    120
    After a long research, there are memory consumptions I know:
    1. WebAssembly code compiled size. If you have 30M uncompressed code size, It would eat-up 150M more or less
    2. Heap, depends on your game content and logic. Typically maybe 64M~256M
    3. Cavas, depends on resolution
    4. Textures, only support DXT compressed texture. On mobile, it will eat-up 4x memory more than desktop browser.
    5. Audio, WebGL build seams to heave some problem. Audio uses much more memory than apps.
    6. JS Memory, interact between C# and JS or some other allocation in JS.

    If you sum them up, It would be much larger than you think.
     
  3. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
  4. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    Those 4k textures are going to be loaded uncompressed on iOS Safari, at 67MB each. That's 268MB only for textures.

    Also, the allocation limit for a browser tab is lower than for an app.
     
  5. OceanX000

    OceanX000

    Joined:
    Feb 24, 2021
    Posts:
    120
    Yep.On iPhone 6s/7/8, safari mem limitation is 1G, while app is 1.3G more or less.