Search Unity

URP memory issues on low-end hardware

Discussion in 'Universal Render Pipeline' started by ElegantMetal, Jun 3, 2021.

  1. ElegantMetal

    ElegantMetal

    Joined:
    Oct 17, 2015
    Posts:
    11
    I wanted to try and implement URP to increase performance on low-end hardware. Overall, this has been pretty successful. However, I'm now getting out of memory crashes where I've never seen them before on the cheap laptops I've been testing on.
    Our game lets people place foliage/trees, and the textures on these are really high quality, but after placing a bunch of different objects it runs out of memory and crashes on laptops. Ultimately I will probably need to reduce the resolution of the textures in the application, but I was pretty surprised to see these out of memory issues where I wasn't getting them before.
    The handful of forum posts I've found on this have said that URPs memory usage should be the same, if not a little less. Is this maybe just referring to RAM and not the GPUs memory?
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Likely you've enabled different features. URP isn't the same renderer as built in so you might have more shadows, or more buffers like depth enabled without realising it. You just need more time with it, and to experiment with less is more strip it down, add it back test by test.

    Pretty sure if URPs configured the same it should be the same memory consumption.

    If you're serious about forum help you'll need to post way more info including versions of all the bits you are using etc.
     
  3. ElegantMetal

    ElegantMetal

    Joined:
    Oct 17, 2015
    Posts:
    11
    Sorry about the vagueness, I wasn't exactly sure where to look next or what my options were, but your response was super helpful. Sure enough, I had a lot of things enabled in my URP settings that I didn't realize were enabled at all. I'll start by disabling some of those and checking performance/visuals and go from there. Thanks so much!
     
  4. ElegantMetal

    ElegantMetal

    Joined:
    Oct 17, 2015
    Posts:
    11
    Ok, I've done some testing, and unfortunately haven't gotten any good results, just confusing ones.

    First off, here's the high/mid range laptop I'm targeting at the moment:
    Processor 11th Gen Intel(R) Core i5-1135G7 @ 2.40ghz (on board graphics only, no additional card)
    RAM: 8.00GB (7.71 GB available)
    Available Physical Memory: 4.26GB
    Available Virtual Memory: 8.12GB
    64 bit Windows OS

    Here's the settings I recently tried:
    upload_2021-6-3_14-41-19.png

    Additionally, I worked with the asset bundles we're using. To reduce memory usage I used scaling to reduce the amount of different tree's we're using, reducing each asset bundles size by about 75%. This should also ensure that more trees on the ground are using the exact same materials, as they're just scaled up/down versions of similar trees.

    We also had encrypted these asset bundles, and unencrypting those bundles at runtime was using a ton of memory. To see if it would help with this memory issue, I have been using just the standard unencrypted asset bundles in the builds.
    Even with all of these changes, I can only manage to get down about 8-9 different tree species down on the ground before I run out of memory in my URP build. In comparison, although the performance is unusably bad, the legacy build can get ALL of the species bundles (24 in total) on the ground even with the assets bundles being encrypted and not reduced in size.
    A really strange aspect of this problem that I ran into while testing was that not all of the species need to be spawned in order to get the out of memory crash. For instance, I placed down bundles 'A' 'B' 'C' 'D', deleted them, then placed bundles 'E' 'F' 'G' 'H' and even though I've checked to make sure the first 4 bundles are being unloaded after they've been placed, after I place the 2nd set of 4 bundles I got a crash.

    Thanks again so much for any suggestions!
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    What version of URP are you using, and are there any post process volumes being used? It looks pretty slimmed down to me. Could it be there's a non-urp reason for the memory problem? Maybe some additional materials referencing textures are in Resources folder or something like that, that got left around in the switch to URP? Resources will load the entire folder into memory for example.

    Have a look at profiling the memory next.
     
  6. ElegantMetal

    ElegantMetal

    Joined:
    Oct 17, 2015
    Posts:
    11
    Unfortunately I won't have a ton of time to work on this today or this weekend, but I'll be back on it in full force Monday. I'm not sure what URP version I'm in, I installed it in Unity 2020.3.7f1. I'm not using any post processing volumes at the moment, I have some I want to put back in that I had in Legacy but I'm leaving them out for now until the memory problem is fixed. As far as the resources folder, almost all the assets in the game are placed at runtime. The only thing in there are the thumbnail images for the objects. Everything else like terrain objects are Addressables that I load/unload depending on the selected terrain.

    I do agree however that this is TOTALLY something I'm incorrectly managing memory-wise. My bewilderment is just how it could be any different from legacy pipeline to URP. I can't find anything talking about any differences under the hood on bundle memory management differences or even anything relating to that. I do have terrains that are just inactive, and not set up with the Addressables system. The terrains are yet another thing that has (needlessly) high resolution textures. Maybe those are using more memory in URP?

    I'll start Monday and make a developer build and see what I get. Thanks again for your help.
     
  7. ElegantMetal

    ElegantMetal

    Joined:
    Oct 17, 2015
    Posts:
    11
    So, this problem just got even more interesting. Today, I switched back over to the legacy branch of our project to fix an issue before the weekend. I fixed the small problem, made a build to test, and there's the memory issue. It's on my powerful desktop computer, in the legacy pipeline. I was very frustrated with myself, but at least excited to realize this wasn't a URP problem and I could narrow my search. But just to make sure, I tried a build of this exact branch my co worker made before the end of the day to see if I could create the problem. Nothing, no out of memory error, no additional memory being used, same as usual.
    So now I'm not sure how to categorize this issue anymore. At the moment it seems like my builds have been messed up sometime after installing the URP a couple of weeks ago. It's hard to pinpoint exactly when, because there were so many issues when I first implemented URP that if this was happening right after I started working on it it would have been swept under the rug.
    To summarize, if I make a build of a branch, I get a out of memory issue. If my coworker makes a build on the exact same branch, no memory issue

    EDIT: Also to clarify, I've tested the builds on multiple pc's. All my builds on all other pc's get out of memory, all builds from my coworker do not get out of memory errors
     
    Last edited: Jun 4, 2021
  8. Hornkvern

    Hornkvern

    Joined:
    Mar 6, 2020
    Posts:
    7
    Have you found a fix for this..? Having the same problem and its happening frequently now