trimMemory

Dispatches a memory pressure signal to registered callbacks. Use this to notify Lynx to reclaim resources or apply degradation strategies when the system is under memory pressure.

Syntax

Android

@AnyThread
public void trimMemory(@MemoryPressureLevel int pressure);

iOS

- (void)trimMemory:(LynxMemoryPressureLevel)pressure;

Harmony

public trimMemory(pressure: MemoryPressureLevel): void;

Parameters

  • pressure: Memory pressure level, one of MemoryPressureLevel.
    • MEMORY_PRESSURE_LEVEL_NONE: No problems, enough memory; typically not sent via callback.
    • MEMORY_PRESSURE_LEVEL_MODERATE: Free buffers that are cheap to re-allocate and not immediately needed.
    • MEMORY_PRESSURE_LEVEL_CRITICAL: Free all possible memory; otherwise the process may be killed by the system, incurring cold start cost.

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.