MemoryEvent

Native memory pressure event dispatched from the host environment and delivered to the front end via the native context. The event name is __OnLowMemory, and the payload is a single MemoryPressureLevel enum value.

Payload

MemoryPressureLevel

enum MemoryPressureLevel {
  MEMORY_PRESSURE_LEVEL_NONE = 0,
  MEMORY_PRESSURE_LEVEL_MODERATE = 1,
  MEMORY_PRESSURE_LEVEL_CRITICAL = 2,
}

Usage

// Add one or multiple listeners
lynx
  .getNative()
  .addEventListener('__OnLowMemory', (level: MemoryPressureLevel) => {
    if (level === MemoryPressureLevel.MEMORY_PRESSURE_LEVEL_CRITICAL) {
      // handle critical memory pressure
    }
  });

lynx
  .getNative()
  .addEventListener('__OnLowMemory', (level: MemoryPressureLevel) => {
    // parallel listener
  });

Compatibility

LCD tables only load in the browser

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.