Search Unity

When the AR module is frequently turned on/off, the memory usage is too large.

Discussion in 'Handheld AR' started by WellC, Aug 10, 2018.

  1. WellC

    WellC

    Joined:
    Mar 2, 2015
    Posts:
    48
    • Unity version : 2018.2.0f2(64bit)
    • ARPlugin: ARFoundation 1.0.0-preview .17 & ARKit XR Plugin 1.0.0-preview.13
    • Run device:iPhone6s
    • Device OS :iOS12 beta-5
    No ARKit.jpg Turn on ARkit.jpg
     

    Attached Files:

    Last edited: Aug 10, 2018
  2. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    719
    I facing also the same issue.
     
  3. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    554
    Are you saying ARKit uses more memory than expected, or that repeatedly restarting the session leaks memory? ARKit does require extra resources, although 100 MB seems like a lot. I tried toggling it on and off, and saw about a 20 MB difference, but no memory leaks.
     
  4. WolfBeardedLion

    WolfBeardedLion

    Joined:
    Apr 5, 2013
    Posts:
    27
    I have managed to get a variety of iOS devices to crash by turning the ARPlaneManager script off and on.

    You can test this by enabling the script when a touch is detected and then disabling the script when no touch is detected. After some tapping you will notice performance loss and screen flickering, and then the application will crash eventually.
     
  5. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    719
    Hey,

    Thanks for reply.

    App crashed with arkit 2 in iOS 12. Every time when I am using ar section it's increase memory.
     
  6. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    554
    Arkit 2? Which plugin are you using? This doesn't sound like the one delivered via package manager and compatible with ARFoundation.
     
  7. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    719
  8. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    554
  9. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    719
    Sorry for posting in the wrong post.
    Thanks for the reply.
    How to solve my issue?
    MY app crashing when memory reached a limit.
     
  10. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    554
    I'm not aware of any known issues related to this. Could you file a bug report and include the crash callstack? You might also try searching the ARKit specific forum.
     
  11. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    719
  12. NSWell

    NSWell

    Joined:
    Jul 30, 2017
    Posts:
    48
    Thank you for your reply!
    --------------------------------------------------------------------
    I switched between 2 different scenes.
    A Scene: Normal scene
    |-MainCamear
    |-UICanvas
    |-Button: Load ARFoundtaion scene.
    |-Directional Light
    |-EventSystem
    B Scene: ARFoundation scene
    |-MainCamear
    |-UICanvas
    |-Button: Load Normal scene.
    |-Directional Light
    |-EventSystem
    |-AR Session Orgin
    |-AR Session
    |-Focus(Quad)
    ---
    This is my test record.

     
  13. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    719
    Hey,
    I am facing the same issue in arkit 2 from bitbucket.
    Which version of ios are You using? (Beta 12 or 11)
     
  14. NSWell

    NSWell

    Joined:
    Jul 30, 2017
    Posts:
    48
    ARfoundtaion and ARKit 2.0(From bitbucket) has the same issue!
    My OS version is 12 Beta 8.
     
  15. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    719
  16. NSWell

    NSWell

    Joined:
    Jul 30, 2017
    Posts:
    48
  17. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    719
  18. NSWell

    NSWell

    Joined:
    Jul 30, 2017
    Posts:
    48
  19. WellC

    WellC

    Joined:
    Mar 2, 2015
    Posts:
    48
  20. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    554
    I haven't been able to reproduce it using ARFoundation and iOS 11.3. Perhaps it is specific to beta 12?

    Please submit a bug report with attached project that reproduces the issue, or let me know if there is an existing case number (I haven't seen one yet).
     
  21. jyves69

    jyves69

    Joined:
    Jan 3, 2014
    Posts:
    9
    Hi,
    we have some memory problem on ios12 too (but not with the AR-Kit)

    When we launch an empty application with unity on ios12 you loose 75MB relatively to the same application on ios11.

    Here the test we do with Unity2017.4.3f1 (up ios11, bottom ios12 beta 12) :

    EmptyProject_ios11_VS_ios12.png

    Do you have some informations about this problem ?
     
  22. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    554
    That seems more like a general iOS problem and not specific to ARKit. You might find an answer on the iOS forum or the Unity issue tracker. If not, please file a bug report.
     
  23. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    554
    Hi folks -- the memory leak on iOS 12 has been fixed in the ARKit XR Plugin version 1.0.0-preview.15.
     
    austin_unity382 likes this.
  24. WellC

    WellC

    Joined:
    Mar 2, 2015
    Posts:
    48
    Thank you!!! It's a good news!
     
  25. zhuty111

    zhuty111

    Joined:
    Nov 1, 2017
    Posts:
    6
    Hi the old ARKit plugin from AssetStore also have this problem ,the ARKit Plugin has been removed from AssetStore. I found it at https://bitbucket.org/Unity-Technologies/unity-arkit-plugin/ Our project has released,So if I use the ARKit XR Plugin version 1.0.0-preview.15 from the UnityPackage ,I have too much code to rewrite,So how can I solve this problem without using the ARKit XR Plugin version 1.0.0-preview.15?
     
  26. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    554
    The bitbucket plugin has been deprecated and won't be updated, though I believe the memory leak was also fixed there too (around a year ago according to the commit history). Do you have any idea what the delta is between the latest bitbucket plugin and what you are using?
     
  27. zhuty111

    zhuty111

    Joined:
    Nov 1, 2017
    Posts:
    6
    Finally I changed my plugin from UnityARkitPlugin to ARFoundation ,it's ok. ah...it is really a huge work,ARFoundation is the future,I'm learning it now.
     
  28. ANTONBORODA

    ANTONBORODA

    Joined:
    Nov 16, 2017
    Posts:
    6
    Seems like the issue is still present even with AR Foundation. Repeated scene reloading still increases memory usage by about 100MB on each scene load.
    Is there anything specific that needs to be disposed or destroyed before switching scenes?
     
    Last edited: Nov 7, 2019
    HVRAT likes this.
  29. HVRAT

    HVRAT

    Joined:
    Aug 28, 2018
    Posts:
    9
    Run into same problem here.
     
  30. NSWell

    NSWell

    Joined:
    Jul 30, 2017
    Posts:
    48
    Are u using ARFoundatin preview 3.x?
    This issu fixed in ARFoundatin 2.0 . But still on 3.x.
     
  31. HVRAT

    HVRAT

    Joined:
    Aug 28, 2018
    Posts:
    9
    I am using preview.1 - 3.1.0
     
  32. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    233
    This leak is definitely still present. I have a project where one scene has AR stuff, but two other scenes don't, so the ARFoundation rig gets destroyed and re-instated every time the scene loads. It's for an installation, so it has to run for hours while going through the scene cycle and the leak is killing the app after only a few cycles.

    Destroying and creating the rig leaks around 100 megs each time. I am thinking about re-working it so that the rig stays via DontDestroyOnLoad, but I just conducted a test and found that simply turning the AR rig on and off still leaks. Not nearly as much, but definitely leaking. Here is the graph from Xcode showing me turning it on and off... note the gradual rise. After about 20 on/offs, it has leaked about 260mb

    upload_2019-12-21_10-49-34.png

    This is on an iPad Pro running iOS 13 and ARFoundation 3.0.1
     
    luispedrofonseca likes this.
  33. zhuty111

    zhuty111

    Joined:
    Nov 1, 2017
    Posts:
    6
    Yes,you are right.At first I use the old arkit plugin from the assetstore have this problem,and then I change it to ARFoundation2.0 it is ok,but now,I'm using ARFoundation3.0 to develop humanbody tracking,the memory leak issue appeared again.
     
  34. SpencerIO

    SpencerIO

    Joined:
    Oct 8, 2013
    Posts:
    5
    +1 for the ARFoundation 3.0 issue
    This is causing me issues when trying to load and unload with 'Unity as a Library'
     
  35. SpencerIO

    SpencerIO

    Joined:
    Oct 8, 2013
    Posts:
    5
    AR Foundation 2.1.4 seems like it is the most stable

    Running Unity 2019.3f6

    Still a 3-4mb leak per reload
     
unityunity