The full explainer is available on this github page.
We propose adding a
The proposed API improves upon the existing non-standard
performance.memory API in the following ways:
- promise-based interface: it allows the implementation to do more work on demand without janking the web page. No overhead for web pages that do not use the API;
- optional support for per-frame memory breakdown of the result;
As shown in this collection of use cases there is a need for an API that measures memory footprint of web pages in production.
The use cases include a) analysis of correlation between memory usage and user metrics, b) detection of memory regressions, c) evaluation of feature launches in A/B tests, d) memory optimization.
Currently web developers resort to the non-standard
performance.memory API that is used in 20% of page loads in Chrome.
Process memory API
Note that the two proposals are complementary and can share the same interface. For example, the interface proposed here can be extended to include a
processMemory field once the process memory proposal is unblocked in future.
Memory pressure API
There is a proposal for memory pressure API that notifies the application about system memory pressure events. This gives the application an opportunity to change its behavior at runtime to reduce its memory usage if possible e.g. by freeing up caches and unused resources. Our proposal has different use cases such as collecting telemetry data and detecting regressions. Thus the two proposals are orthogonal.