Skip to content
On this page

useMemory

响应式获取内存信息

Reactive Memory Info.

例子

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/zh-CN/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 type UseMemoryReturn = ReturnType<typeof useMemory>
/**
 * Performance.memory
 *
 * @see  https://developer.mozilla.org/zh-CN/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 type UseMemoryReturn = ReturnType<typeof useMemory>

Source

Category
Export Size
1.14 kB
Last Changed
18 hours ago

SourceDemoDocs

贡献者(Contributors)

日志(Changelog)

No recent changes

Released under the MIT License.