WorkerNavigator: deviceMemory property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is only available in Web Workers.

The deviceMemory read-only property of the WorkerNavigator interface returns the approximate amount of device memory in gigabytes.

The reported value is imprecise to curtail fingerprinting. It's approximated by rounding the actual value to the nearest power of 2, then dividing that number by 1024. It is then clamped within lower and upper bounds to protect the privacy of owners of very low-memory or high-memory devices. These bounds may change over time (see browser compatibility table).

Value

A floating point number coarsened to a power of two value, clamped to implement-defined limits.

For example, if a browser does not report below 2 or above 32 then the value is one of: 2, 4, 8, 16, 32.

Examples

The following code can be run in a worker:

js
const memory = navigator.deviceMemory;
console.log(`This device has approximately ${memory}GiB of RAM.`);

Specifications

Specification
Device Memory API
# sec-device-memory-js-api

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
deviceMemory
Chrome – Full support
Chrome 65 (Release date: 2018-03-06)
footnote
footnote From Chrome 147, reported values are 2, 4, 8, 16, and 32.
footnote Before Chrome 147, reported values are 0.25, 0.5, 1, 2, 4, and 8.
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote
footnote From Edge 147, reported values are 2, 4, 8, 16, and 32.
footnote Before Edge 147, reported values are 0.25, 0.5, 1, 2, 4, and 8.
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 52 (Release date: 2018-03-22)
footnote
footnote From Opera 131, reported values are 2, 4, 8, 16, and 32.
footnote Before Opera 131, reported values are 0.25, 0.5, 1, 2, 4, and 8.
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 65 (Release date: 2018-03-06)
footnote
footnote From Chrome 147, reported values are 1, 2, 4, and 8.
footnote Before Chrome 147, reported values were 0.25, 0.5, 1, 2, 4, and 8.
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 47 (Release date: 2018-07-23)
footnote
footnote From Chrome 147, reported values are 1, 2, 4, and 8.
footnote Before Chrome 147, reported values were 0.25, 0.5, 1, 2, 4, and 8.
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 9 (Release date: 2018-09-15)
footnote
footnote From Chrome 147, reported values are 1, 2, 4, and 8.
footnote Before Chrome 147, reported values were 0.25, 0.5, 1, 2, 4, and 8.
WebView Android – Full support
WebView Android 65 (Release date: 2018-03-06)
footnote
footnote From Chrome 147, reported values are 1, 2, 4, and 8.
footnote Before Chrome 147, reported values were 0.25, 0.5, 1, 2, 4, and 8.
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

See also