fn

useMemory

v0.0.14testeddemo

Reactive performance.memory heap statistics, polled on an interval. SSR-safe and a no-op where the API is unavailable.

Examples

ts
const { isSupported, memory } = useMemory();
// memory.value?.usedJSHeapSize
ts
// Poll every 500ms
const { memory } = useMemory({ interval: 500 });

Demo

Loading demo…

Signature

ts
export function useMemory(options: UseMemoryOptions ={ ... }

Parameters

ParameterTypeDescription
options?UseMemoryOptionsConfiguration options

Returns

UseMemoryReturn{ isSupported, memory }
PropertyTypeDescription
isSupportedComputedRef<boolean>Whether performance.memory is available in the current environment.
memoryShallowRef<MemoryInfo | undefined>The latest performance.memory snapshot, or undefined until the first sample is read (or when unsupported).