コンテンツへスキップ

useMemory

カテゴリ
エクスポートサイズ
524 B
最終変更日
先週

リアクティブメモリ情報

デモ

お使いのブラウザはパフォーマンスメモリAPIをサポートしていません

使用方法

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.dokyumento.jp/useMemory
 * @param options
 */
export declare function useMemory(options?: UseMemoryOptions): {
  isSupported: ComputedRef<boolean>
  memory: Ref<MemoryInfo | undefined, MemoryInfo | undefined>
}
export type UseMemoryReturn = ReturnType<typeof useMemory>

ソース

ソースデモドキュメント

コントリビューター

Anthony Fu
Jelf
Anthony Fu
webfansplz

変更ログ

v12.0.0-beta.1 2024/11/21
0a9ed - feat!: Vue 2サポートの削除、バンドルの最適化、クリーンアップ (#4349)

MITライセンスの下でリリースされています。