Unity 2022.3.13f1 consume memory too much!

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!!!

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://discussions.unity.com/t/841163/2

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://discussions.unity.com/t/846847/2

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

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?

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


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?)

  • 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.)

  • 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

  • Import the snapshot taken in 2021 via the 1.1.0 Memory Profiler Package UI in 2022

  • Switch the left-top-hand-side mode from Single to Compare

  • 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.

9470924--1331114--Unity_VqCYRJVwSB.png
That's the Import button btw, as it might not be as obvious with the icon

2 Likes

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.

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.

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.


I have been using 2022.3.20 and experiencing this same issue. I've never seen it before. I will try running my project in an older version of unity to see if i still end up with the same issues.

1 Like

for now I switch to 2022.3.21f1 and everything seem to be Ok now,
so I don't want to dare update Unity anymore...


Have you been able to take memory snapshots to see what's up?