8000 GitHub - EricRahm/memory-api-experiment: WebExtension memory experimental API · GitHub
[go: up one dir, main page]

Skip to content

About

WebExtension memory experimental API

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebExtension memory experimental API

This project contains the implementation of the Firefox brwoser.memory API.

API

memory.getInfo()

Returns a promise that will resolve to an object containing memory details for each process. Each process is identified by it's PID, except for the main process which is labeled as "Parent." Currently only rss and uss are supported.

{
  "Parent":
   {
     "uss": 1234,
     "rss": 4567
   },
   "67890":
   {
     "uss": 1234,
     "rss": 4567
   }
}

memory.onLowMemory

An event that is triggered when low memory is detected. This can be used to proactively clear caches and attempt to reduce overall memory used by your WebExtension. Examples:

const callback = (data) => { console.log(`low memory: ${data}`); }

// register for the event
browser.memory.onLowMemory.addListener(callback);

// unregister from the event
browser.memory.onLowMemory.removeListener(callback)
5C67
;

Testing

Note: This was lifted from the logins experiment, there might be a better way to do things.

  1. From a mozilla-central source tree, create a symlink for test/test_ext_memory.js in the webextensions xpcshell directory with the command:

    ln -s (path/to/this/repo)/test/test_ext_memory.js toolkit/components/extensions/test/xpcshell
  2. Add the following line to toolkit/components/extensions/test/xpcshell/xpcshell.ini:

    [test_ext_memory.js]
  3. Re-build the test database (./mach build or your favorite more targetted variant)

  4. Run the test:

    ./mach test toolkit/components/extensions/test/xpcshell/test_ext_memory.js

About

WebExtension memory experimental API

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0