Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.rebellapp.com/llms.txt

Use this file to discover all available pages before exploring further.

Use this API to stop listening for memory warning events that were registered with my.onMemoryWarning().

Parameters

PropertyTypeRequiredDescription
callbackFunctionNoThe specific callback to remove. If omitted, all listeners are removed.

Code Example

Remove All Listeners

// Remove all memory warning listeners
my.offMemoryWarning();

Remove Specific Listener

Page({
  onLoad() {
    my.onMemoryWarning(this.handleMemoryWarning);
  },

  handleMemoryWarning(res) {
    console.log('Memory warning:', res.level);
    this.releaseResources();
  },

  onUnload() {
    my.offMemoryWarning(this.handleMemoryWarning);
  },

  releaseResources() {
    this.setData({ cachedImages: [] });
  }
});

Conditional Memory Monitoring

Page({
  data: {
    monitoringMemory: false
  },

  startMemoryMonitoring() {
    my.onMemoryWarning(this.onMemoryWarning);
    this.setData({ monitoringMemory: true });
  },

  stopMemoryMonitoring() {
    my.offMemoryWarning(this.onMemoryWarning);
    this.setData({ monitoringMemory: false });
  },

  onMemoryWarning(res) {
    console.log('Memory level:', res.level);
  }
});
Pass the same callback function reference to my.offMemoryWarning() that was used with my.onMemoryWarning() to remove only that specific listener.

my.onMemoryWarning

Listen for memory warnings