In a Unity3D - Android project .. how to get memory warnings?

1.4k Views Asked by At

How to be alerted of memory warnings? Unity3D, building to Android.

Cheers.

2

There are 2 best solutions below

3
meredrica On

There is no inbuilt function for this in Android as far as I know.

0
mayo On

You can subscribe to Application.lowMemory Documentation

For example, in some monoBehaviour starting your game:

private void Start() 
{
    Application.lowMemory += ReportSystemLowMemory;
} 


private void ReportSystemLowMemory() 
{
    Debug.LogWarning("Warning: Low memory");
}
  • Be sure to don't subscribe ReportSystemLowMemory more than once.
  • Also unsubscribing it would be a good practice, ie Application.lowMemory -= ReportSystemLowMemory when you are close your app/game.