Skip to content

useMemory

反应式内存信息。

¥Reactive Memory Info.

示例

Your browser does not support performance memory API

用法

¥Usage

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

const { isSupported, memory } = useMemory()

类型声明

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: ComputedRef<boolean>
  memory: Ref<MemoryInfo | undefined, MemoryInfo | undefined>
}
export type UseMemoryReturn = ReturnType<typeof useMemory>

源代码

源代码示例文档

变更日志

No recent changes

VueUse 中文网 - 粤ICP备13048890号