Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Editor runs slow after a few minutes

Discussion in 'Editor & General Support' started by BigGameCompany, Jun 28, 2023.

  1. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    107
    I am using version 2020.3.30 and after a few minutes (5-10) the editer slows down and becomes unusable. I restart the editor and speed is back to normal but again after a few minutes it start to slow again. What is happening?
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    I would would profile the editor to see where the overhead is coming from.
     
    KillDashNine likes this.
  3. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    It's not supposed to do that. Likely some asset you're using is running bogus editor code.

    Another thing to note is that Unity can take up some memory. If your machine is close to running out of RAM, it will start paging its memory, which will create considerable waits. So check your available RAM and paging settings.
     
  4. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    107
    Thanks for help....i ran the profiler .... so the culprit looks to be Application.WaitForAsyncOperation....how do i fix this?
    Screenshot 2023-06-29 at 12.34.32 pm.png
     
  5. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Seems your culprit is GC.MarkDependencies and GC in general, which points to a mass of objects created and abandoned in runtime.

    This could be created by, say, a single asset stuck into a loop in which it's just creating objects.

    Can you profile the memory and see who's doing it?
     
  6. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
  7. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    107
    I think i fixed it by deleting a scene from the project that i wasnt using...
     
  8. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Just an idea, but a common cause for masses of unnecessary objects created is when working with large text files using simply concatenation (plus operator). Every concatenation creates a new object and this overloads GC in a flash. The correct way is to use a builder class of some kind.
     
    CodeSmile likes this.
  9. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    107
    KillDashNine likes this.
  10. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    If you don't work on the scene or load it at runtime, I don't see how this could cause it.
     
  11. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    107
    @Jaakk0S ...you are right the problem is back....here is the memory profiler Screenshot 2023-06-29 at 3.06.33 pm.png
     
  12. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    107
    I am not using large text files.
     
  13. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    You probably want to enable deep profiling to get a further breakdown of what's happening.
     
  14. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    107
    i believe this is slowing th editor down but what is it?

    Screenshot 2023-06-29 at 4.32.17 pm.png
     
  15. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,140
    That would be managed allocations that lead to issues with GC.Collect. GarbageCollectAssetsProfile is a marker that measures the AssetGC, or Resources.UnloadUnusedAssets(), to free up native memory by unloading Assets. It usually has to be triggered explicitly or through a scene load, but the Editor can also trigger it if the OS is signaling the EditorApp that it is running out of available memory. Deep Profiling can use up a lot of memory for all the data points it collects and increase the memory pressure, triggering it even more than it would happen without profiling.

    So check your Task Manager for how much RAM is still available in total as you might be running out of it. You can also use the Asset Loading and File Access profiler modules to get more details on what loading operations might have been going on on that frame and before that might have led to the Editor triggering the AssetGC. In one screenshot here I can see a significant jump in Material Count and Texture Memory, while the Asset GC seems to have successfully lowered overall memory usage. But loading these textures might have triggered it.

    Also, the CPU Usage module's Timeline view can give you details of what loading operations happens on the loading thread and when you enable Flow Event visualization, you can trace the entire AsyncLoad operation for these assets. Selecting single load operations within that flow also shows the Asset file name loaded in the operation. The Asset Loading module gathers this data for you so you don't have to hunt it all down in Timeline but Timeline can give you extra details and context.
     
    spiney199 and KillDashNine like this.
  16. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
  17. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    107
    Gents...I am 100% sure it is not one of my scripts...must be a script used by the editor...perhaps in a package....but how do i find which one?

    And my mac has pleny of RAM remaining so that not the cause.
     
    Last edited: Jun 29, 2023
  18. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    107
    Ok the issue commences when i exit play mode .....

    Screenshot 2023-06-30 at 12.19.15 am.png
     
  19. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Your activity happens under GarbageCollectAssetsProfile, and @MartinTilo suggested that somebody is might be explicitly calling
    Resources.UnloadUnusedAssets()
    . You should run profiler with his suggestions to get more info. I suggest rgrep:ing (grep -r) your Assets folder and package cache directories for "UnloadUnusedAssets" to find which of your assets or packages are using that in the first place.
     
  20. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,140
    And searching for AssetDatabase.Refresh as suggested by @CodeSmile. Also, depending on your setup, your IDE might include package code in its search too so it might just be a Find All or Find Usage Of operation on these two that would be needed.

    That is, unless after loading back into the default scene after Playmode there isn't some code triggering continuous scene reloads. Then scene load API calls should also be searched for.
     
  21. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    This would seem like the most probable thing that would cause a sudden extreme spike of asset loads. Somebody unintentionally triggering a scene load.
     
  22. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    107
    Thanks for your help everyone. I used the profiler as suggested (had to upgrade my version of unity) and now i get this error code after playmode...i am 100% sure this is the problem... how do i fix this? google came up with nothing.

    Screenshot 2023-06-30 at 6.42.01 am.png
     
    KillDashNine likes this.
  23. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,140
    Is your version of Visual Studio up to date? If yes, I'd say please report a bug via the Unity Editor menu
    Help > Report A Bug
    .
     
  24. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    107
  25. BigGameCompany

    BigGameCompany

    Joined:
    Sep 29, 2016
    Posts:
    107
    For anyone else that may have this error i fixed it by running the profiler and locating the problem file which was located in a temp folder in my library. It was using the AssetDatabase.Refresh line. Some assest must have put the file there. Anyway i deleted it, then upgraded visual pro to the latest version and issue went away.
     
    KillDashNine and MartinTilo like this.