StorageArea.getBytesInUse()

Gets the amount of storage space, in bytes, used by one or more items stored in the storage area.

Note: In Firefox this method:

This is an asynchronous method that returns a Promise.

Syntax

js
let gettingSpace = browser.storage.<storageType>.getBytesInUse(
  keys                      // null, string, or array of strings
)

Where <storageType> is one of the storage types — sync, local, session, or managed.

In Firefox, <storageType> can't be storage.local, because of bug 1385832.

Parameters

keys

A key (string) or keys (an array of strings) to identify the items whose storage space you want to retrieve. If an empty array is passed in, 0 is returned. If you pass null or undefined, the function returns the space used by the entire storage area.

Return value

A Promise that is fulfilled with an integer, bytesUsed, representing the storage space used by the objects specified in keys. If the operation fails, the promise is rejected with an error message.

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
getBytesInUse

Legend

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

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

Note: This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.