Skip to content
On this page

useMemory

Category
Export Size
1.14 kB
Last Changed
5 months ago

Reactive Memory Info.

Demo

Your browser does not support performance memory API

Usage

ts
import { useMemory } from '@vueuse/core'

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

const { isSupported, memory } = useMemory()

Type Declarations

typescript
/**
 * 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)
v8.9.2 on 7/12/2022
81d92 - fix(all)!: isSupported becomes Ref instead of boolean for SSR compatibility (#1800)
v8.9.0 on 7/6/2022
6f7cd - fix!: rename type MemoryOptions to UseMemoryOptions (#1605)
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)

Released under the MIT License.