Firefox Tomorrow

web api instance property

WorkerNavigator: deviceMemory property

View on MDN ↗

Secure contextAvailable in 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:

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

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also