# wx.onMemoryWarning(function callback)

Start from base library version 2.0.2. Please remaining backward compatible.

Listens on the insufficient memory alarm event.

This event is triggered when iOS/Android sends an insufficient memory alarm to the Mini Program process. Triggering this event does not mean that the Mini Program will be terminated. In most cases, it is only an alarm. Developers can reclaim some unnecessary resources after receiving the alarm to free up memory space.

# Parameters

# function callback

The callback function for the insufficient memory alarm event.

# Parameters

# Object res
Property Type Description
level number Memory alarm level, only available in Android. It corresponds to the system macro definition.

Valid values of level

Value Description Minimum Version
5 TRIM_MEMORY_RUNNING_MODERATE
10 TRIM_MEMORY_RUNNING_LOW
15 TRIM_MEMORY_RUNNING_CRITICAL

# Sample Code

wx.onMemoryWarning(function () {
  console.log('onMemoryWarningReceive')
})
``