Another problem I'm noticing is that this large spike in memory doesn't get released when I transition out of the ViewController hosting ARView
Following is a summary of profiling a skeleton AugmentedReality app
AugmentedReality app built with ARKit + RealityKit template is resulting in large memory footprint
With no code changes to the template app created by Xcode, Im noticing about 450MB of memory usage on iPhone 13 Pro Max
When I profiled and looked at live-objects while ARExperience is running, here are the top allocations:
Here are the heavy memory regions:
VIRTUAL RESIDENT DIRTY SWAPPED VOLATILE NONVOL EMPTY REGION
REGION TYPE SIZE SIZE SIZE SIZE SIZE SIZE SIZE COUNT (non-coalesced)
=========== ======= ======== ===== ======= ======== ====== ===== =======
IOSurface 146.2M 129.2M 129.2M 0K 0K 44.0M 0K 100
MALLOC_LARGE 85.4M 58.5M 58.5M 0K 0K 0K 0K 372 see MALLOC ZONE table below
IOAccelerator 178.4M 34.3M 34.3M 0K 4480K 29.9M 320K 152
VM:IOSurface: 159MB
non-Object: 56MB
Here's the breakdown of IOSurface:
2 * 13.38MB (QuartzCore) CAMetalLayer Display Drawable shared with backboardd; // CoreRE on callstack
32 * 3.03MB (CMCapture)
3 * 784KB (CoreVideo)
non-objects:
16MB (AppleCV3D)
2.94MB (CoreRE)
2 * 2.36MB (AppleCV3D)
1.02MB (CoreRE)
Many more AppleCV3D non-objects
To check if this memory goes away when I transition out of the viewcontroller, I added an initial-view controller with a button to transition into the VC hosting ARView.
When I transition out, memory remains close to the peak memory and does NOT go back to what it was before launching into AR-experience.
Here are the heavy memory regions:
VIRTUAL RESIDENT DIRTY SWAPPED VOLATILE NONVOL EMPTY REGION
REGION TYPE SIZE SIZE SIZE SIZE SIZE SIZE SIZE COUNT (non-coalesced)
=========== ======= ======== ===== ======= ======== ====== ===== =======
IOSurface 173.7M 156.6M 156.6M 0K 0K 44.0M 0K 110
MALLOC_LARGE 84.2M 73.6M 71.3M 2048K 0K 0K 0K 317
IOAccelerator 182.5M 38.4M 38.4M 0K 8832K 29.7M 320K 154
This time even though I have transitioned out of ViewController hosting ARView, Im still seeing
3 * 13.38MB (QuartzCore) CAMetalLayer Display Drawable shared with backboardd; // CoreRE on callstack
Im still seeing a similar number of IOSurface and non-objects
How can I properly cleanup after user is done using AR experience i.e transitioned out of ViewController hosting ARView
Topic:
Spatial Computing
SubTopic:
ARKit
Tags: