# uni.onMemoryWarning(UTSCallback)

监听内存不足告警事件。

# onMemoryWarning 兼容性

Web 微信小程序 Android iOS
x 4.41 x x

# 参数

名称 类型 必填 默认值 兼容性 描述
callback (result: OnMemoryWarningCallbackResult) => void - - -

# OnMemoryWarningCallbackResult 的属性值

名称 类型 必备 默认值 兼容性 描述
level number -
仅 Android 有该字段,对应系统内存告警等级宏定义

# 参见

# uni.offMemoryWarning(callback?)

取消监听内存不足告警事件。不传入 callback 则取消所有监听。

# offMemoryWarning 兼容性

Web 微信小程序 Android iOS
x 4.41 x x

# 参数

名称 类型 必填 默认值 兼容性 描述
callback (result: OffMemoryWarningCallbackResult) => void - - -

# OffMemoryWarningCallbackResult 的属性值

名称 类型 必备 默认值 兼容性 描述
level number -
仅 Android 有该字段,对应系统内存告警等级宏定义

# 参见

# 通用类型

# GeneralCallbackResult

名称 类型 必备 默认值 兼容性 描述
errMsg string -
错误信息