Performance: measureUserAgentSpecificMemory() method - Web APIs | MDN Skip to main content Skip to search MDN HTML HTML: Markup language HTML reference Elements Global attributes Attributes See all… HTML guides Responsive images HTML cheatsheet Date & time formats See all… Markup languages SVG MathML XML CSS CSS: Styling language CSS reference Properties Selectors At-rules Values See all… CSS guides Box model Animations Flexbox Colors See all… Layout cookbook Column layouts Centering an element Card component See all… JavaScriptJS JavaScript: Scripting language JS reference Standard built-in objects Expressions & operators Statements & declarations Functions See all… JS guides Control flow & error handing Loops and iteration Working with objects Using classes See all… Web APIs Web APIs: Programming interfaces Web API reference File system API Fetch API Geolocation API HTML DOM API Push API Service worker API See all… Web API guides Using the Web animation API Using the Fetch API Working with the History API Using the Web speech API Using web workers All All web technology Technologies Accessibility HTTP URI Web extensions WebAssembly WebDriver See all… Topics Media Performance Privacy Security Progressive web apps Learn Learn web development Frontend developer course Getting started modules Core modules MDN Curriculum Check out the video course from Scrimba, our partner Learn HTML Structuring content with HTML module Learn CSS CSS styling basics module CSS layout module Learn JavaScript Dynamic scripting with JavaScript module Tools Discover our tools Playground HTTP Observatory Border-image generator Border-radius generator Box-shadow generator Color format converter Color mixer Shape generator About Get to know MDN better About MDN Advertise with us Community MDN on GitHub Blog Toggle sidebar Web Web APIs Performance measureUserAgentSpecificMemory() Theme OS default Light Dark English (US) Remember language Learn more Deutsch English (US) 日本語 한국어 Performance: measureUserAgentSpecificMemory() method Limited availability This feature is not Baseline because it does not work in some of the most widely-used browsers. Want more browser support for this feature? Tell us why. Learn more See full compatibility Note: This feature is available in Web Workers. Experimental: This is an experimental technology Check the Browser compatibility table carefully before using this in production. The measureUserAgentSpecificMemory() method is used to estimate the memory usage of a web application including all its iframes and workers. In this article Syntax Description Security requirements Examples Specifications Browser compatibility See also Syntax js measureUserAgentSpecificMemory() Parameters None. Return value A Promise that resolves to an object containing the following properties: bytes A number representing the total memory usage. breakdown An Array of objects partitioning the total bytes and providing attribution and type information. The object contains the following properties: bytes The size of the memory that this entry describes. attribution An Array of container elements of the JavaScript realms that use the memory. This object has the following properties: url If this attribution corresponds to a same-origin JavaScript realm, then this property contains the realm's URL. Otherwise it is the string "cross-origin-url". container An object describing the DOM element that contains this JavaScript realm. This object has the following properties: id The id attribute of the container element. src The src attribute of the container element. If the container element is an <object> element, then this field contains the value of the data attribute. scope A string describing the type of the same-origin JavaScript realm. Either "Window", "DedicatedWorkerGlobalScope", "SharedWorkerGlobalScope", "ServiceWorkerGlobalScope" or "cross-origin-aggregated" for the cross-origin case. types An array of implementation-defined memory types associated with the memory. An example return value looks like this: json { "bytes": 1500000, "breakdown": [ { "bytes": 1000000, "attribution": [ { "url": "https://example.com", "scope": "Window" } ], "types": ["DOM", "JS"] }, { "bytes": 0, "attribution": [], "types": [] }, { "bytes": 500000, "attribution": [ { "url": "https://example.com/iframe.html", "container": { "id": "example-id", "src": "redirect.html?target=iframe.html" }, "scope": "Window" } ], "types": ["JS", "DOM"] } ] } Exceptions SecurityError DOMException Thrown if the security requirements for preventing cross-origin information leaks aren't fulfilled. Description The browser automatically allocates memory when objects are created and frees it when they are not reachable anymore (garbage collection). This garbage collection (GC) is an approximation since the general problem of determining whether or not a specific piece of memory is still needed is impossible (see also JavaScript Memory Management). Developers need to make sure that objects are garbage collected, memory isn't leaked, and memory usage doesn't grow unnecessarily over time leading to slow and unresponsive web applications. Memory leaks are typically introduced by forgetting to unregister an event listener, not closing a worker, accumulating objects in arrays, and more. The measureUserAgentSpecificMemory() API aggregates memory usage data to help you find memory leaks. It can be used for memory regression detection or for A/B testing features to evaluate their memory impact. Rather than make single calls to this method, it's better to make periodic calls to track how memory usage changes over the duration of a session. The byte values this API returns aren't comparable across browsers or between different versions of the same browser as these are highly implementation dependent. Also, how breakdown and attribution arrays are provided is up to the browser as well. It is best to not hardcode any assumptions about this data. This API is rather meant to be called periodically (with a randomized interval) to aggregate data and analyze the difference between the samples. Security requirements To use this method your document must be in a secure context and cross-origin isolated. You can use the Window.crossOriginIsolated and WorkerGlobalScope.crossOriginIsolated properties to check if the document is cross-origin isolated: js if (crossOriginIsolated) { // Use measureUserAgentSpecificMemory } Examples Monitoring memory usage The following code shows how to call the measureUserAgentSpecificMemory() method once every five minutes at a random interval using Exponential distribution. js function runMemoryMeasurements() { const interval = -Math.log(Math.random()) * 5 * 60 * 1000; console.log(`Next measurement in ${Math.round(interval / 1000)} seconds.`); setTimeout(measureMemory, interval); } async function measureMemory() { const memorySample = await performance.measureUserAgentSpecificMemory(); console.log(memorySample); runMemoryMeasurements(); } if (crossOriginIsolated) { runMemoryMeasurements(); } Specifications Specification Measure Memory API # ref-for-dom-performance-measureuseragentspecificmemory⑤ Browser compatibility Enable JavaScript to view this browser compatibility table. See also setTimeout() Monitor your web page's total memory usage with measureUserAgentSpecificMemory() - web.dev Help improve MDN Was this page helpful to you? Yes No Learn how to contribute This page was last modified on Nov 30, 2025 by MDN contributors. View this page on GitHub • Report a problem with this content Filter sidebar Clear filter input Performance APIs Performance Instance properties eventCounts interactionCount memory navigation timeOrigin timing Instance methods clearMarks() clearMeasures() clearResourceTimings() getEntries() getEntriesByName() getEntriesByType() mark() measure() measureUserAgentSpecificMemory() now() setResourceTimingBufferSize() toJSON() Events resourcetimingbufferfull Inheritance EventTarget Related pages for Performance API EventCounts LargestContentfulPaint LayoutShift LayoutShiftAttribution NotRestoredReasonDetails NotRestoredReasons PerformanceElementTiming PerformanceEntry PerformanceEventTiming PerformanceLongAnimationFrameTiming PerformanceLongTaskTiming PerformanceMark PerformanceMeasure PerformanceNavigation PerformanceNavigationTiming PerformanceObserver PerformanceObserverEntryList PerformancePaintTiming PerformanceResourceTiming PerformanceScriptTiming PerformanceServerTiming PerformanceTiming TaskAttributionTiming VisibilityStateEntry Window.performance WorkerGlobalScope.performance Guides Performance data High precision timing Long animation frame timing Resource timing Navigation timing User timing Server timing Monitoring bfcache blocking reasons MDN Your blueprint for a better internet. MDN About Blog Mozilla careers Advertise with us MDN Plus Product help Contribute MDN Community Community resources Writing guidelines MDN Discord MDN on GitHub Developers Web technologies Learn web development Guides Tutorials Glossary Hacks blog Mozilla Website Privacy Notice Telemetry Settings Legal Community Participation Guidelines Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.