Search Issue Tracker

By Design

Votes

0

Found in

2022.3.61f1

6000.0.46f1

6000.1.0b14

6000.2.0a8

Issue ID

UUM-102820

Regression

No

[iOS] Memory leak when unloading Unity as a Library

-

How to reproduce:
1. Open the “Untitled.xcworkspace“ file in Xcode (Unzip the “TheXcodeSetup.zip“)
2. Open the “FinalLeak.zip“ project
3. Build for iOS
4. Link the “Unity-iPhone.xcodeproj“ file to the “Untitled.xcworkspace”
5. Expand the “Unity-iPhone.xcodeproj“ and click on the “Data“ folder
6. In the Target Membership section add “UnityFramework“
7. Click on the “Unity-iPhone.xcodeproj“ and then General
8. In “Frameworks, Libraries, and Embedded Content“ add the “UnityFramework.framework“
9. Open the “Xcode > Open Developer Tools > Instruments“
10. Open the Allocator
11. Build the “testApp“ to a device
12. Attach the Allocator to the application and start recording (after 10s Unity will get loaded, so the Allocator needs to be attached in that time frame)

Expected result: The memory consumption does drop back to the initial amount when Unity is unloaded
Actual result: The memory consumption does not drop back to the initial amount when Unity is unloaded

Reproducible with: 2022.3.61f1, 6000.0.46f1, 6000.1.0b14, 6000.2.0a8

Reproducible environment: macOS 15.3.1  (M4 Max)
Not reproducible environment: No other environment tested

Reproducible with these devices:
VLNQA00535, iPhone XS (MT9F2ET/A), CPU: Apple A12 Bionic, GPU: Apple designed, OS: 17.6.1
VLNQA00416, iPhone 13 Pro (MLVA3ET/A), CPU: Apple A15 Bionic, GPU: Apple designed, OS: 16.1.1
VLNQA00626, iPhone 16 (MYE73QN/A), CPU: Apple A18 Pro, GPU: Apple designed, OS: 18.3.1
VLNQA00232, iPhone 8 Plus (MQ8M2ET/A), CPU: Apple A11 Bionic, GPU: Apple designed, OS: 16.7.10
VLNQA00600,  iPad Pro (9.7 inch, WiFi), CPU: Apple A9X, GPU: Apple designed, OS: 14.8

Not reproducible with these devices:
VLNQA00518, Google Pixel 4 (Pixel 4), Android 13, CPU: Snapdragon 855 SM8150, GPU: Adreno (TM) 640

Notes:
- Does not seem to reproduce when using Unity as a library with an Android device ([https://github.com/Unity-Technologies/uaal-example/blob/master/docs/android.md|https://github.com/Unity-Technologies/uaal-example/blob/master/docs/android.md])
- The Unity project consist just with an empty scene
- running unity with “runEmbeddedWithArgc“ unloading with “unloadApplication“
- More information in the comments

  1. Resolution Note:

    When Unity is unloaded in Unity as a Library setup, it retains some amount of memory. This is an expected behavior and it is specified in our generic UaaL documentation page https://docs.unity3d.com/Manual/UnityasaLibrary.html as well as iOS specific documentation page https://docs.unity3d.com/Manual/UnityasaLibrary-iOS.html

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.