Skip to content
On this page

useMemory

Category
Last Changed
5 months ago

Reactive Memory Info.

Demo

Your browser does not support performance memory API

Usage

import { useMemory } from '@vueuse/core'

const { isSupported, memory } = useMemory()
import { useMemory } from '@vueuse/core'

const { isSupported, memory } = useMemory()

Type Declarations

/**
 * Performance.memory
 *
 * @see https://developer.mozilla.org/en-US/docs/Web/API/Performance/memory
 */
export interface MemoryInfo {
  /**
   * The maximum size of the heap, in bytes, that is available to the context.
   */
  readonly jsHeapSizeLimit: number
  /**
   *  The total allocated heap size, in bytes.
   */
  readonly totalJSHeapSize: number
  /**
   * The currently active segment of JS heap, in bytes.
   */
  readonly usedJSHeapSize: number
  [Symbol.toStringTag]: "MemoryInfo"
}
export interface MemoryOptions extends IntervalFnOptions {
  interval?: number
}
/**
 * Reactive Memory Info.
 *
 * @see https://vueuse.org/useMemory
 * @param options
 */
export declare function useMemory(options?: MemoryOptions): {
  isSupported: boolean
  memory: Ref<MemoryInfo | undefined>
}
/**
 * Performance.memory
 *
 * @see https://developer.mozilla.org/en-US/docs/Web/API/Performance/memory
 */
export interface MemoryInfo {
  /**
   * The maximum size of the heap, in bytes, that is available to the context.
   */
  readonly jsHeapSizeLimit: number
  /**
   *  The total allocated heap size, in bytes.
   */
  readonly totalJSHeapSize: number
  /**
   * The currently active segment of JS heap, in bytes.
   */
  readonly usedJSHeapSize: number
  [Symbol.toStringTag]: "MemoryInfo"
}
export interface MemoryOptions extends IntervalFnOptions {
  interval?: number
}
/**
 * Reactive Memory Info.
 *
 * @see https://vueuse.org/useMemory
 * @param options
 */
export declare function useMemory(options?: MemoryOptions): {
  isSupported: boolean
  memory: Ref<MemoryInfo | undefined>
}

Source

SourceDemoDocs

Contributors

Anthony Fu
webfansplz
jelf

Changelog

v7.6.2 on 2/13/2022
0e1e2 - fix(useFps,useMemory): ssr support (#1244)
v7.1.1 on 11/25/2021
bd234 - fix: import path
v6.9.2 on 11/19/2021
8508d - feat: new function (#923)
useMemory has loaded