Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
2.98k stars 1.11k forks source link

Memory Leaks #1101

Open kanda110681 opened 9 months ago

kanda110681 commented 9 months ago

report

I have recently integrated the AR Session and XR Origin components into my project while using default settings such as OpenGL ES3, IL2CPP, and 64-bit support. However, it appears that there is a memory leak issue occurring without any additional features or functionalities added to the project.

I am currently working on an AR application where I create a virtual environment and navigate based on AR tracking. When I collide with vertical planes, I intend to activate the device's back camera. The logic appears to be functioning correctly, but after a few seconds, my app freezes. Upon analyzing the memory profiler, I discovered the presence of memory leaks.

Is there a potential problem with ARFoundation, or am I implementing it incorrectly?

To Reproduce Steps to reproduce the behavior: Try with ARFoundation example with above mentioned configurations (Unity 2022.3.4f1 and ARFoundation 5.0.7)

Expected behavior There may be slight memory leaks acceptable. Here kept leaking progressively.

Actual behavior Check with Unity memory profiler take snapshot at one time, after 4 minutes take anothery snapshot. Compare the both snapshot you could see the memory leaks (Unknow category), and take another snap shot after some time, memory keeps increasing.

Smartphone (please complete the following information): Unity Version: 2022.3.4f1 ARFoundation: 5.0.7 Google ARCore XR Plugin: 5.0.7 My Testing Android Device: Pixel 4a (Android version 13)

andyb-unity commented 9 months ago

Is there a potential problem with ARFoundation, or am I implementing it incorrectly?

You haven't shared any information about your implementation, so it's hard to say. Generally issues like this happen when a developer retains IDisposable memory and does not dispose it, or allocates NativeArrays using Allocator.Persistent, and never frees them. We are not aware of any such issues in the AR Foundation 5.0.7 API.

Steps to reproduce the behavior: Try with ARFoundation example with above mentioned configurations (Unity 2022.3.4f1 and ARFoundation 5.0.7)

Which AF Foundation sample scene do you mean? Are you able to reproduce this issue with the sample app in this repo? You have not shared enough information for us to attempt to reproduce this issue.

kanda110681 commented 9 months ago

You haven't shared any information about your implementation, so it's hard to say. Generally issues like this happen when a developer retains IDisposable memory and does not dispose it, or allocates NativeArrays using Allocator.Persistent, and never frees them. We are not aware of any such issues in the AR Foundation 5.0.7 API.

I have not added any code. I simply attached the AR Session and XR Origin components to an empty game object. There is no additional code implemented.

Which AF Foundation sample scene do you mean? Are you able to reproduce this issue with the sample app in this repo? You have not shared enough information for us to attempt to reproduce this issue.

I used the following scene to test for memory leaks: Scene: AR Foundation Samples Plane Detection ->Feathered Planes arfoundation_profile_1

andyb-unity commented 9 months ago

Thanks for the followup information. This should be enough for us to investigate.