Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

HoloLens Memory Loss

Discussion in 'AR/VR (XR) Discussion' started by dpmontes, Sep 17, 2020.

  1. dpmontes

    dpmontes

    Joined:
    Dec 7, 2018
    Posts:
    14
    Hello, I am trying to understand why it appears that memory is not getting deallocated enough. I included a chart which reflects the memory state given by the MRTK 2.4 Memory Profiler in the HoloLens. When the app starts, around 220 MB are used. Instantiating 100,000 cubes raises the memory by 200 MB. Calling Destroy on each cube only lowers the memory usage by 50 MB. I also call System.GC.Collect() and that helps a little more. And I also try reloading the scene but that again only helps a little. After 3 instances of instantiating cubes and Destroying them all, explicitly calling garbage collection and reloading the scene, I am still missing some 400MB of memory compared to when I started. The HoloLens profiler shows a max of 900MB and in practice the app will crash at about 1400MB.

    Is the HoloLens memory profiler showing the size of the heap which isn't getting reduced on purpose? Or is there something else I can do to reduce the memory usage so my app doesn't crash too soon? Thanks!
     

    Attached Files:

  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Just to try to limit the problem space here: If you strip out MRTK and run the Unity profiler, do you still see the same memory usage issue?

    If you keep MRTK and run the Unity profiler do you see different memory statistics than MRTK is reporting?
     
  3. dpmontes

    dpmontes

    Joined:
    Dec 7, 2018
    Posts:
    14
    I feel I can't really limit the problem space well since I am looking at the MRTK profiler in the HoloLens to provide the memory usage information so I can't strip out MRTK and see the values in the HoloLens.

    It's difficult to even compare the MRTK app running on the HoloLens to the same app running on the editor because the starting memory values are always 400MB or so more than on the HoloLens and the editor shows a max of 32,000 MB instead of the 900 MB on the HoloLens.

    If I look at the Unity profiler while running the same application I was on the HoloLens (MRTK included), the profiler seems to show a much better reduction in "Total Allocated" memory. The memory returns to within .04 GB of the starting memory after two rounds of creating 300,000 cubes and erasing them and calling some GC explicitly.
     
  4. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    You should be able to attach the unity profiler to the app on the Hololens and profile through that as well.
     
  5. dpmontes

    dpmontes

    Joined:
    Dec 7, 2018
    Posts:
    14
    That sounds good, I wasn't aware that was possible. Do you have a link to anything that could point me in right direction? I thought the Unity Profiler was only possible to view when running in the Editor.
     
  6. dpmontes

    dpmontes

    Joined:
    Dec 7, 2018
    Posts:
    14
  7. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
  8. aortega13

    aortega13

    Joined:
    Jul 29, 2022
    Posts:
    1
    Hello, could you find the problem related with the MRTK profiler?