Reputation: 229
I am looking to track the memory consumption of our application / web page over fixed intervals on different clients. My team would like to observe this metric in understanding if any new feature roll outs have significant impact to the memory consumed by the app and rollback the feature if it does so.
I've read up on these sources:
First, if we look at the old API: window.performance
The user must enable accurate memory monitoring by starting Chrome with the "--enable-precise-memory-info" flag. To me, it doesn't seem reasonable to expect our users to run Chrome with this flag.
I also read that this API could over or under measure the memory consumption because it measures the size of the JavaScript Heap which could be incorrect if there are iframes or service workers which start a different heap or if there are any large web pages that are on the same heap.
Because of these two reasons, this option is not a valid option (imo) for the goal of frontend observability on real clients in production.
Second, if we look at the new API: performance.measureMemory()
.
It is only available via an origin trial till Jan, 2021 (as per what the form told me when I signed up for a token).
Beyond local profiling on dev machines, this seems to be the only alternative at the moment to achieve what I'm looking to achieve above (or am I mistaken in my assumption?).
I have two questions regarding the usage of the API:
#enable-experimental-web-platform-features
without any issues. I have an origin trial token and if I add this as a meta tag to my index.html
, do my users need any flags enabled on their browser in order for us to observe this?Upvotes: 3
Views: 2424
Reputation: 229
I reached out to the editor of the measure memory API w3c specification who was kind enough to get back to me with a prompt response.
I am now posting the answers I got on email here, in case someone else comes looking for this:
We are planning to ship it in Chrome 89. Due to security reasons it will be guarded by the self.crossOriginIsolated. The version that is currently shipping in the origin trial doesn't require cross-origin isolation.
If you add the meta-tag, then the users don't need any flags. Note that without --enable-blink-features='ForceEagerMeasureMemory' it may take a while (up to 20seconds) until the promise with the result resolves. That's because the API waits until the next garbage collection to perform the measurement.
Upvotes: 3