# wx.onMemoryWarning(function callback)

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

with Promise style call: Not supported

Mini Program plugin: Not supported

Listens for out-of-memory warning events.

when iOS/Android This event is triggered when a memory warning is issued to the Mini Programs process. Triggering the event does not mean that the Mini Program is killed. In most cases, it is just an alarm. Developers can recover some unnecessary resources after receiving the notification to avoid further aggravating memory strain.

# parameter

# function callback

Callback function for out-of-memory warning event

# parameter

# Object res
attribute type Introductions
level number Memory alert level, only Android There is, corresponding to the system macro definition

level Legal value

value Introductions 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')
})