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

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

Discussion in '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. TechnicalArtist

    TechnicalArtist

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

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    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. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    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

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

    TechnicalArtist

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

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
  9. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    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

    Joined:
    Apr 21, 2017
    Posts:
    605
    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. TechnicalArtist

    TechnicalArtist

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

    NSWell

    Joined:
    Jul 30, 2017
    Posts:
    89
    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. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    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:
    89
    ARfoundtaion and ARKit 2.0(From bitbucket) has the same issue!
    My OS version is 12 Beta 8.
     
  15. TechnicalArtist

    TechnicalArtist

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

    NSWell

    Joined:
    Jul 30, 2017
    Posts:
    89
  17. TechnicalArtist

    TechnicalArtist

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

    NSWell

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

    WellC

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

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    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

    Joined:
    Apr 21, 2017
    Posts:
    605
    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

    Joined:
    Apr 21, 2017
    Posts:
    605
    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

    Joined:
    Apr 21, 2017
    Posts:
    605
    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:
    52
    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
    HypeVR likes this.
  29. HypeVR

    HypeVR

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

    NSWell

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

    HypeVR

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

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    305
    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:
    8
    +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:
    8
    AR Foundation 2.1.4 seems like it is the most stable

    Running Unity 2019.3f6

    Still a 3-4mb leak per reload
     
  36. GHSmediaSrl

    GHSmediaSrl

    Joined:
    Dec 2, 2015
    Posts:
    12
    I'm facing the same issue with ARFoundation 3.0.1 and iPhone 7 running iOS 13.
    I need ARFoundation 3 in order to detect AR planes.

    Please Unity repair this issue.
     
    Last edited: Feb 24, 2020
  37. GHSmediaSrl

    GHSmediaSrl

    Joined:
    Dec 2, 2015
    Posts:
    12
    Also AR Foundation 3.1.0 preview 4
     
  38. robenu

    robenu

    Joined:
    Oct 1, 2018
    Posts:
    11
    Ar Foundation 3.0.1
    unity 2019.2.21
    ipap pro 11 inch

    Same issue and no solution yet
     
    Last edited: Mar 4, 2020
  39. todds_unity

    todds_unity

    Joined:
    Aug 1, 2018
    Posts:
    324
    Please try out:

    com.unity.xr.arfoundation@3.1.0-preview.7
    com.unity.xr.arkit@3.1.0-preview.7
    com.unity.xr.arkit-face-tracking@3.1.0-preview.7 [optional]

    We fixed some memory leaks in these packages.

    Unfortunately, there is still a 3~4 MB per scene-switch leak still existing even with these changes. This other leak seems to be coming from ARKit itself.
     
  40. robenu

    robenu

    Joined:
    Oct 1, 2018
    Posts:
    11
    It works. Thank you
     
    todds_unity likes this.
  41. HypeVR

    HypeVR

    Joined:
    Aug 28, 2018
    Posts:
    11
    From the data in XCode, the memory is stable with 3.1.0-preview.7. However it still crashes with "Message from debugger: Terminated due to memory issue" after several times of reloading the scene.