Search Issue Tracker

By Design

Votes

0

Found in

2018.4

2018.4.33f1

2019.4

2020.3

2021.1

2021.2

Issue ID

1326094

Regression

No

[Android] Application.lowMemory event not raised before application runs out of memory and crashes

Mobile

-

Reproduction steps:
1. Open the attached project "AppLowMemoryBug_2018_4_33.zip"
2. Open the Profiler window
2. Build to device with Autoconnect Profiler enabled
3. Watch the Memory section of the Profiler go up
4. See the console log for 'Low Memory, unloading unused assets (X)' where X is the number of times the assets have been unloaded
5. See the Memory section of the Profiler unload the assets
6. Repeat steps 3-5 until the app crashes on the device

Expected result: Application.lowMemory event is raised before the application runs out of memory
Actual result: application crashes before Application.lowMemory event is raised

Reproduces on: 2018.4.33f1, 2019.4.24f1, 2020.3.3f1, 2021.1.2f1, 2021.2.0a12

Reproducible with these devices:
N/A, Samsung Galaxy S9 (SM-G960F), Android 8.0.0, CPU: Exynos 9 Series 9810, GPU: Mali-G72
VLNQA00318, Oneplus 7Pro (GM1913), Android 10, CPU: Snapdragon 855 SM8150, GPU: Adreno (TM) 640
VLNQA00231, Huawei HUAWEI Mate 20 Pro (LYA-L29), Android 9, CPU: HiSilicon Kirin 980, GPU: Mali-G76
VLNQA00339, Lge LG V50 ThinQ 5G (LM-V500N), Android 10, CPU: Snapdragon 855 SM8150, GPU: Adreno (TM) 640

Not reproducible with these devices:
iPad Pro 12.9 1st gen (iOS 13.4.1)
iPhone 5C (iOS 10.3.3)

Notes:
-Customer tested using; Xiaomi Mi5, Asus ZenFone 5, Lenovo A536, Samsung Galaxy S7 and Ipad mini 3
-On Samsung Galaxy S9 and OnePlus 7Pro after a second or third memory unload the event is no longer raised and the app crashes
-In 2018.4 you will see a 'System out of memory' error in the console, in 2019.4 and up no error is shown in the console
-Reproducible with Mono and IL2CPP scripting backends

  1. Resolution Note (2021.2.X):

    This is by design due to several reasons:
    - There is no strong guarantee that the callback will be called
    - It is documented, that this callback is tied to relevant Operating System events, so the whether this event happens or not depends on Operating System
    - The project continuously allocates memory every frame, while Android documentation explicitly warns that such behavior may lead to OS closing application before an event occurrs: https://developer.android.com/games/optimize/memory-allocation
    - It's not specifically documented, what "memory" means in this context, however, out of several runs I did, in all cases this project crashes due to running out of graphics memory, so it seems it's not a general memory pressure, but a very specific out of GPU memory case.

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.