Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

XBOX ONE DevMode UWP memory leak

Discussion in 'Windows' started by IElectric, Jul 14, 2019.

  1. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    114
    Hello, I'm testing my UWP game on Windows 10 and XBOX ONE, the same game build consume different memory between PC and Console.

    Console continue consume memory during the game execution istead the same PC version doesn't has this problem, in the script code I'm using also System.GC.Collect() function.

    On Console after 1.1 GB of memory consumption the game is closed, probably is the DevMode memory limit, does anyone know this kind of problem ? Thank you very much, Best regards...

    xbobmemory.png
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,338
    What version of Unity are you on? I haven't heard this happening before. Are you using .NET or IL2CPP scripting backend? Did you try changing the setting on Xbox for your game to run it in "Game mode", as opposed to "App mode"?
     
  3. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    114
    Hello, I'm using

    Unity 2019.1.10f1
    Visual Studio Community 2017 15.9.14
    XBOX ONE X Dev Mode July 2019 OS VERSION 10.0.18362.5047

    This is my build configuration :

    Config.png

    When I start the same UWP game in the same time on XBOX ONE and PC WINDOWS 10 the memory consumption in both main menu is different, on PC 314 MB on XBOX 724 MB :

    3.png

    This is the main menu :

    Main.png

    When I play the game match on both platform in the same time the memory consumption on PC 386 MB on XBOX 1.1 GB :

    4.png

    This is the game match :

    Match.png

    When the game match start my script code load the players texuters from the resources folder and write the number on each Tshirt.

    Before load each player texture from the resources folder the script destroy the existing texture and after all call the garbage collector function like this :

    //Material textures
    private Texture2D TextureLabel = null;
    private Texture2D TextureNormal = null;

    //All the model material existing texture are destroyed
    if(this.TextureLabel != null) GameObject.Destroy(this.TextureLabel );
    if(this.TextureNormal != null) GameObject.Destroy(this.TextureNormal);

    //The new textures are loaded
    TextureLabel = Texture2D.Instantiate((Texture2D)Resources.Load("UsaTexture1M"));
    TextureNormal = Texture2D.Instantiate((Texture2D)Resources.Load("UsaNormal1M" ));

    //...write number on Tshirt and then apply the modification on texture
    TextureLabel.Apply();

    //Update the material of each player's model
    this.GetComponentInChildren<Renderer>().material.SetTexture("_MainTex", TextureLabel);
    this.GetComponentInChildren<Renderer>().material.SetTexture("_BumpMap", TextureNormal);

    //And then free the allocated memory
    Resources.UnloadUnusedAssets();
    System.GC.Collect();

    Seems that destroy texture or UnloadUnusedAssets doesn't works on XBOX ONE Dev Mode.

    I can't test it on XBOX ONE Retail mode and I don't know if in Retail mode works properly until I will publish an update of my game.

    Sadly I can't publish an update of my game until this issue https://forum.unity.com/threads/uwp-twice-xrsettings-enabled-true-crash-and-exit-game.602755/ will be fixed on the latest Unity version, please let me know your opinion, Thank you very much, Cheers...

    PS: my UWP game on Windows 10 doesn't has the memory leaks problem, the game works around 400 MB and has a short peak when the new textures are loaded, on XBOX ONE Dev mode when I reach over 1.1 GB the game is closed due to the Dev Mode limits...
     
    Last edited: Jul 16, 2019
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,338
    You're not comparing the same thing. The Xbox screenshot you posted shows commit size, rather than private working set size. To see the same on PC in the task manager, you have to go to Details -> right click on columns -> Select columns -> enable Commit size -> OK. Besides, don't forget Xbox One doesn't have dedicated GPU memory, so you need to add VRAM usage to that number too.

    I don't really think that any of those functions work differently on Xbox because the code that runs on Xbox is the same. However, I could always be wrong :).

    My bigger concern is Xbox killing your game when it reaches 1.1 GB. If you look here, it says games should be able to use 5 GB memory. Are you sure that you configured your game as "Game" in the developer mode settings?

    I also asked our XR team about the bug reported... I'll let you know if I hear anything back.
     
  5. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    114
    Yes, you are right, I have found the developer mode settings as "Game" and now I can properly test my videogame on XBOX ONE in Dev Mode.

    mode.png
    1_3.png

    During the game the commit memory stays around 1.1-1.3 GB and the game doesn't close, I have also discovered that if I run the game in Visual Studio as remote Debug, istead of run without debugging, I can go over app 1 GB limits .

    Thank you a lot also for your intersting on my XR issue, I hope to publish soon a new update of uVolley, Cheers...
     
    Last edited: Jul 17, 2019