Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug Editor use too much memory resource.

Discussion in '2022.1 Beta' started by Spikebor, Mar 31, 2022.

  1. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    Unity 2022.1.0b14, Windows 11, HDRP.

    I test build a game scene, the game player uses only 1GB of memory, very nice.
    But in the Editor, the Unity Editor take 16GB after opening a asset layout scene ( which has many assets to build environment )

    What I expect is, same as player, we only load what is currently shown in current scene, not every assets we have. And unload unused assets every time we change scene in Editor.

    The scene is just one asset pack laying out. And I intend to use many asset packs to build my world. If the memory usage explode like this, I have to buy more RAM, yes RAM is cheap, but I suspect this is some sort of bug ? 16 GB of memory for one asset pack is not normal.

    I write an editor script to manually call UnloadUnusedAssetsImmediate, but it does not help.

    I then download HDRP sample project, load the scene, and see it only use 3gb of memory.

    Then I import a forest asset pack and load it's sample scene, the memory usage burst to 8gb.

    So the problem is easily reproducible : just load more asset packs, and open their scenes. The memory will explode.

    I will not upload my project as it is too heavy, but as procedure mentioned above, you guy can test with any of your environment asset packs, load their scene and see memory usage go up.

    I will surely buy more RAM sticks for development, but as the same time I hope you guy can help with this issue.
    Thank you!
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Editor shouldn't be loading every asset in your project. Did you try using the memory profiler to see what is taking up the memory?
     
  3. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    My bad, I shouldn't say It load all my assets. I just don't expect an asset layout scene can crash my Unity with huge memory usage.

    I'm still not familiar with how to inspect the memory profiler. From what I see the textures are taking up 7.4gb, but my system (32GB total, 24GB spare when Unity Editor is not opened) crashed. So the texture2D is huge, but is still just a part of why it crash.

    What should I specifically inspect in this board other than the texture2D ?

     
  4. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    I test build the same scene, and the Player only taking 1GB of memory.
    So it's not the scene and it's textures or shaders that taking up my resources.

     
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    Can you check the settings for
    Wall_02_Nor
    and post a screenshot from the Inspector showing the texture settings and preview?
     
  6. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    I see, so it's 4k normal map. Then I'll try to make all the texture to 2k and see memory usage.

     
  7. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    Btw I just close Unity and reopen with an empty scene, it already taking up ~10GB of memory. Is this normal ?



    Then I capture memory profiler snapshot, it shoot up to 14GB. Still in the empty scene.

     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    No, definitely not. Unity with an empty scene uses just above 1 GB of memory on my machine.

    In the task manager if you expand Unity, does all the usage come from a single process?
     
  9. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    Thanks for clarifying. So it's definitely a bug. I'll try to pack the project and fire a bug report.

    Nothing scene, expanded unity process, still 7GB taken.

     
  10. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    Hello bro, I need another clarification before submitting a huge 60GB project contain many of my assetstore's assets.

    This memory issue seems to only occur in huge project with many assets. Can't reproduce in same version of Unity but in small sample project.

    So the question is : does memory rise up by default ( even in empty scene ) if the asset database is huge ?
     
  11. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    bump! anyone with large project can clarify this ?'
     
    ThynkTekStudio likes this.
  12. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    could you please check what is the Commit memory size of the Editor? ProcessExplorer can show that as a dedicated column (or Resource Monitor).

    Memory Profiler captures Commit Memory set for the process as "Total" on Windows. Task Manager shows afair Working Set which is physical memory used by a process (it is a slice of commit memory which is currently resident in physical memory).
    12Gb or 17Gb of committed memory may be reflected in 6.9Gb of physical memory. That means the rest is not actively used and (potentially) paged out.
    My hypothesis (based on the Managed heap size it is 5.43Gb most of which is not used) is that scripts activity during scene opening caused Mono to expand heap and keep memory blocks alive with very few pages being used.

    If that is so I would suggest minimizing the amount of GC allocations by scripts.
    Would it be possible to use Unity Profiler and record Editor activity when the scene is being opened? That might help to see whether or now there are a lot of GC allocations happening and perhaps find the source of those allcoations.
     
  13. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    Thank you for your detail insight about this. Unfortunately I tried to upload my 60Gb project in bug report tool twice, and it failed twice. I can't provide further info. But please, I believe this is reproducible in any big project. Do you have any comparable project with about 50~100gb in size ? you can test out this issue. An empty scene eat up 7-9gb, so it has nothing to do with scene or scripts, it must be something with how big the asset database is.
     
  14. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,332
    Send the bug report without the project, and include in the text of the bug report that the project is too big for upload. Unity QA will then send you a link to an upload page that handles such uploads.
     
    LeonhardP and MartinTilo like this.
  15. bradbecker

    bradbecker

    Joined:
    Dec 26, 2014
    Posts:
    130
    I'm having some similar problems: upgraded to 2021.3.9f1 and it persists. Have a scene open right now that spiked to 22GB of ram usage (per Taskman tho)--mostly in the "Importing (iteration 2)" process. Any progress on this one?
     
  16. AmmarT

    AmmarT

    Joined:
    Jun 16, 2019
    Posts:
    4
    I am having the same problem I have 32 GB ram and I am building a 10GB Build
     
  17. DavidPaulinus

    DavidPaulinus

    Joined:
    Dec 26, 2017
    Posts:
    2
    I'm having the same issue.
    I wanted to test out to see if was the project I was working on, so I created a new empty 2D project and, to my surprise, the problem continues and, strangely, it's getting more of the memory??
    My editor's version is 2022.3.0f1
     
  18. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,448
    Hi there,
    How are you monitoring the memory usage? Are you using the Memory Profiler Module in the Profiler Window? Do you have the Memory Profiler package installed in your project and if yes, at which version?

    A bit late but as a general tip:
    If your projects are too big to upload via the bug reporter, don't include them in the initial upload but state that you couldn't upload them due to their size and ask for an upload link instead. It might be good to zip up the project in the current state so that you can upload it once you get a reply with an upload link from our QA.
     
  19. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    thank! I'll keep that in mind next time :3
     
    MartinTilo likes this.
  20. yeesgamer

    yeesgamer

    Joined:
    Nov 5, 2022
    Posts:
    2
    Hello I think u must try unity 2019 because give more preformance and low memory usage better then the latest updates
    i compared both 2019 and the latest
    2019 = more 100frames and even get higher and higher
    and use URP for preformance
    and u can use builtin with Aura 2 - Volumetric Lighting & Fog asset
    hdrp is for high end so u dont want this
    Many games on steam uses urp or builtin for 3d

    my advice just u must take a look for unity 2019 urp or (aura builtin)
    thanks
     
    Last edited: Aug 10, 2023
  21. Jdedueas

    Jdedueas

    Joined:
    Nov 23, 2019
    Posts:
    6
    Same thing is happening to me with Unity 2022.3.8f1 on Windows 10, Android platform.
    Edit: Added another screenshot.

    screenshot.PNG


    sc.PNG
     
    Last edited: Sep 12, 2023
  22. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,448
    @Jdedueas the Render Texture part might be a bug. there are some RT leak related fixes, one of which (UUM-46882) landed on 2022.3.10f1 so, that version might make that part better.
    As for the Textures, you will have to go a bit deeper in the Memory Profiler to see what's up with those.
     
  23. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    @MartinTilo
    I'm not really sure on how should I troubleshoot this, it was not happening on 2021 LTS, now as we just upgraded to 2022.3.18 we're getting a very high memory usage at play. It goes way beyond the system ram and starts using a lot of hard drive memory which makes entering play mode unbearably slow. At editor time there seems to be no issue. Also it does not occur on more light scenes.
    upload_2024-1-29_11-11-59.png

    The game eventually enters playmode and this appears

    upload_2024-1-29_11-20-2.png

    Also we started to see memory leak warnings in the console that are new as well and asked us to add -diag-temp-memory-leak-validation launch flag.
     
    Last edited: Jan 29, 2024
  24. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    Just to follow up, we downgraded to 2021.3.34 and on our memory intensive scene the memory consumption, even if high, is much lower and entering playmode takes way less time (1mn vs 5-10) due to less paging happening I believe.

    Here you can see that it's more than half the commit size on 2021 LTS vs 2022 LTS.
    upload_2024-1-29_12-36-46.png
     
    Last edited: Jan 29, 2024
  25. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,448
    I'd try using the Memory Profiler package to analyze this instead. With MemoryProfiler.TakeSnapshot you can trigger an automatic capture to happen before automatically switching to play mode and then capturing again. Store it as a .snap file and then open it in the Memory Profiler window.

    FYI: Instead of the command line option, you can also flip on the similarly named Diagnostic Flag in your Preferences and restart the Editor.
     
    Whatever560 likes this.
  26. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    Thanks, I'll try this out with 2021, 2022 can't seem to be usable with that scene atm. Maybe once we'll have troubleshoot the high memory footprint.
     
  27. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,448
    It might be completely different issues on 2021 but if that helps isolate parts of it, that could be a good start.
     
  28. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    I'm with you, it surely is two unrelated things, 1. the heavy scene consumption 2. 2021 vs 2022 memory management and/or asset loading. By tackling 1 we'd be in a better spot to see how 2 affects us.
     
    MartinTilo likes this.