Search Unity

Question Memory Leak

Discussion in 'Scripting' started by rmele09, Jan 2, 2023.

  1. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    716
    I have a memory leak but not really sure how to solve this issue, here is a picture of the console and the errors its saying. I dont exactly know how to execute what it is telling me to do, any help would be great. I believe this started after installing and using Quixel Megascan assets in a scene. I tried closing the Quixel Bridge plugin but that doesnt help. Thanks for the help in advance! Screenshot (1522).png
     
  2. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    716
    Is the console saying to type that cmd line into the cmd prompt while unity is running, is that what that means? Or is it referring to something else?
     
  3. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    721
    I see this randomly in all of my 2022 projects. I'm not aware of a specific cause.

    I also see that you're getting that "the package cache was invalidated..." warning due to DefaultHDMaterial.mat getting changed, somehow. That one's been a real pest as of late!

    Again, no idea what causes it...but I guess it hasn't really caused problems? It's just a nuisance.

    It's telling you to run unity with extra command-line arguments to see that information. You'd need to navigate to where the Unity executable is stored in a command prompt, then do something like
    ./Unity.exe -some-flag -some-other-flag
    .

    Doing so ought to show who's responsible for these leaked allocations. I might give that a try later today.
     
  4. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    716
    well unfortunately after these errors pop up, unity freezes and stops working after about a minute. so its completely ruining my productivity.
    I don't quite understand how to do what you are saying. How do I find the unity.exe in a command prompt? I only really know how to program in c# in unity, I have never really used a command prompt in this way, could you walk me through executing this in baby steps?
     
  5. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    721
    Ah. I've never had that warning come right before a freeze. It's possible that they're unrelated -- memory leaks are usually long-term problems, where it slowly eats up all of your memory and eventually causes a crash.

    I just tried to do this myself, and it merely opened the Unity Hub. Oops...fortunately, the hub has a way to add command-line arguments!

    Hit the triple-dot icon next to your project.

    upload_2023-1-2_13-7-11.png

    Punch the
    -diag-job-temp-memory-leak-validation
    flag into the text box and hit save, then open the project.

    Even simpler: there's a diagnostic switch for this. Check your user preferences menu (not project settings!).

    upload_2023-1-2_13-11-39.png

    You'll need to restart the editor after turning it on here.
     
    MichaelJT likes this.
  6. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    716
    Thank you so much for this, it looks very helpful. I will try this out and post back any findings!
     
  7. MichaelJT

    MichaelJT

    Joined:
    Jan 28, 2015
    Posts:
    14
    Might be a silly question but how do I actually see what this outputs so I can tell what's causing the issue?
     
    Elli-0 and rmele09 like this.