Skip to content
On this page

useMemory

Reactive Memory Info.

Demo

Category
Last Changed
last month
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 UseMemoryOptions extends UseIntervalFnOptions {
  interval?: number
}
/**
 * Reactive Memory Info.
 *
 * @see https://vueuse.org/useMemory
 * @param options
 */
export declare function useMemory(options?: UseMemoryOptions): {
  isSupported: Ref<boolean>
  memory: Ref<MemoryInfo | undefined>
}
export declare type UseMemoryReturn = ReturnType<typeof useMemory>
/**
 * 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 UseMemoryOptions extends UseIntervalFnOptions {
  interval?: number
}
/**
 * Reactive Memory Info.
 *
 * @see https://vueuse.org/useMemory
 * @param options
 */
export declare function useMemory(options?: UseMemoryOptions): {
  isSupported: Ref<boolean>
  memory: Ref<MemoryInfo | undefined>
}
export declare type UseMemoryReturn = ReturnType<typeof useMemory>

Source

SourceDemoDocs

Contributors

Jelf
Anthony Fu
webfansplz

Changelog

v9.0.0-beta.1 on 7/20/2022
4bc0f - fix(useIntervalFn)!: rename type IntervalFnOptions to UseIntervalFnOptions (#1943)

Released under the MIT License.