Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Unity 2022.3.13f1 consume memory too much!

Discussion in 'Editor & General Support' started by Rachan, Nov 13, 2023.

  1. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    725
    Hi there!

    I was switched my project to Unity 2022.3.13f1 LTS from Unity 2021 LTS
    and I play test on iPad mini 2 by Xcode 15.0.1

    and then I can't even play, it stop by crashed after my game reached splash screen
    it can't even go to the first scene, just stop after splash screen,
    and it show me this on Xcode after crashed

    "UnityGfxDeviceWorker (31): EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=700 MB)"


    and I see a memory using from begin in xcode,
    it was use more and more++ until it more than 700MB then crashed!
    I don't know what happen?

    Actually this same project work fine on Unity 2021LTS and Xcode any version
    the memory usage never more than 300 MB,
    But after Unity 2022.3.13f1 it 700MB++ and unable to play

    I tried to optimize my game as much as possible, my game just 2D sprite game
    the Textures should be the most memory consumer, so I tried to optimize many things,
    such as set a maximum texture not more than 1024 and some compression format
    I just use RBBA32 it should be small right?
    But still can't play...

    so What happen?

    anyone ? Thanks!!!
     
    Last edited: Nov 13, 2023
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,238
    That's not a good approach.

    It sounds like whatever you "optimized" wasn't relevant. This is similar to fixing your neighbor's roof when your own roof is leaking: it just isn't helpful.


    For all performance and optimization issues, ALWAYS start by using the profiler:

    Window -> Analysis -> Profiler

    DO NOT OPTIMIZE "JUST BECAUSE..." If you don't have a problem, DO NOT OPTIMIZE!

    If you DO have a problem, there is only ONE way to find out: measuring with the profiler.

    Failure to use the profiler first means you're just guessing, making a mess of your code for no good reason.

    Not only that but performance on platform A will likely be completely different than platform B. Test on the platform(s) that you care about, and test to the extent that it is worth your effort, and no more.

    https://forum.unity.com/threads/is-...ng-square-roots-in-2021.1111063/#post-7148770

    Remember that you are gathering information at this stage. You cannot FIX until you FIND.

    Remember that optimized code is ALWAYS harder to work with and more brittle, making subsequent feature development difficult or impossible, or incurring massive technical debt on future development.

    Don't forget about the Frame Debugger either, available right near the Profiler in the menu system.

    Notes on optimizing UnityEngine.UI setups:

    https://forum.unity.com/threads/how...form-data-into-an-array.1134520/#post-7289413

    At a minimum you want to clearly understand what performance issues you are having:

    - running too slowly?
    - loading too slowly?
    - using too much runtime memory?
    - final bundle too large?
    - too much network traffic?
    - something else?

    If you are unable to engage the profiler, then your next solution is gross guessing changes, such as "reimport all textures as 32x32 tiny textures" or "replace some complex 3D objects with cubes/capsules" to try and figure out what is bogging you down.

    Each experiment you do may give you intel about what is causing the performance issue that you identified. More importantly let you eliminate candidates for optimization. For instance if you swap out your biggest textures with 32x32 stamps and you STILL have a problem, you may be able to eliminate textures as an issue and move onto something else.

    This sort of speculative optimization assumes you're properly using source control so it takes one click to revert to the way your project was before if there is no improvement, while carefully making notes about what you have tried and more importantly what results it has had.

    "Software does not run in a magic fairy aether powered by the fevered dreams of CS PhDs." - Mike Acton
     
  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,405
    If the game crashes before it reaches the splash screen, using the Profiler gets tricky. Have you tried running on a newer IPhone, an Android or (not a good comparison but if everything else fails) a Desktop standalone build just to profile startup and take a Memory Capture with the Memory Profiler Package (version 1.1.0 or 1.1.0-pre.3)?

    Also if you do anything with RenderTexture in your code or for postprocessing, maybe something didn't like the update and now leaks uncontrollably on startup?
     
  4. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    725
    Thanks you very much for your answers!

    in my project profiler, I see a memory is up to 1.6 GB ++,
    I don't know why this version has more memory consume

     
  5. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,405
    To find out, you need the two versions of you project (I hope you have backed up the project or build in e.g. version control before the upgrade so that this should be possible?)
    1. Take a Memory Snapshot of the 2021 iOS build of the Project (can be from a backup of the Project still running in 2021 with the 0.7 version of the package, or with the upgraded project connected to and profiling the old build, while using the 1.1 version of the package. If you're doing the latter, skip step 3.)
    2. Take a Memory Snapshot with the Memory Profiler Package (version 1.1.0 or 1.1.0-pre.3) in the 2022 version of the Project
    3. Import the snapshot taken in 2021 via the 1.1.0 Memory Profiler Package UI in 2022
    4. Switch the left-top-hand-side mode from Single to Compare
    5. Open both snapshots and look at the Summary page as well as the All Of Memory page to compare where the differences are coming from.
     
  6. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,405
    Unity_VqCYRJVwSB.png
    That's the Import button btw, as it might not be as obvious with the icon
     
    Last edited: Nov 14, 2023
    Rachan and tsukimi like this.
  7. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    725
    Wow! Thank you very much!!

    I just wondering why Unity 2022.3.13f1 still has memory issue like this
    actually this project used to in Unity 2021, it never have this issue at all
    even I never changing or adding anything, everything same.
     
  8. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,405
    I can't give you an answer to that without more details on your particularly project and memory issues. If you could do the diff as I outlined above and share your findings here, I'll look over that and maybe then I can tell you.
     
  9. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,405
    FYI, 2022.3.14f1 released. Have you been able to find a resolution to this issue, and if not, have you tried updating and seeing if that version resolves it? I've heard it resolved some issues for others.