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

BCD tables only load in the browser

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