Performance: memory property

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Non-standard: This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The non-standard and legacy performance.memory property returns the size of the JavaScript heap which can be helpful to measure and reduce the memory footprint of websites.

Note that the information this API provides is unreliable as it might overestimate actual memory usage if web pages share the same heap, or might underestimate actual memory usage if web pages use workers and/or cross-site iframes that are allocated in separate heaps. It is not standardized what "heap" means exactly. The API is only available in Chromium-based browsers.

A new API aiming to replace performance.memory is Performance.measureUserAgentSpecificMemory(). It tries to estimate the memory used by a web page.

Value

The read-only performance.memory property is an object with the following properties:

jsHeapSizeLimit

The maximum size of the heap, in bytes, that is available to the context.

totalJSHeapSize

The total allocated heap size, in bytes.

usedJSHeapSize

The currently active segment of JS heap, in bytes.

Examples

Getting JavaScript heap sizes

Calling performance.memory returns an object like this:

js
{
  totalJSHeapSize: 39973671,
  usedJSHeapSize: 39127515,
  jsHeapSizeLimit: 4294705152
}

Specifications

None.

Browser compatibility

BCD tables only load in the browser

See also