Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance.measureUserAgentSpecificMemory #3159

Closed
emilk opened this issue Nov 20, 2022 · 2 comments · Fixed by #3350
Closed

performance.measureUserAgentSpecificMemory #3159

emilk opened this issue Nov 20, 2022 · 2 comments · Fixed by #3350

Comments

@emilk
Copy link

emilk commented Nov 20, 2022

Motivation

window.performance.memory in an API for accessing the memory use of JavaScript (and by extension, wasm).

Example JS: window.performance.memory.usedJSHeapSize

Proposed Solution

Add a Memory feature flag to expose window.performance.memory with three fields:

  • js_heap_size_limit
  • total_js_heap_size
  • used_js_heap_size

Alternatives

WASM apps can install a custom #[global_allocator] that does its own bookkeeping of amount of RAM used.

Additional Context

Knowing the memory used by a WASM application is useful for it to know whether or not to try free up some memory.

@Liamolucko
Copy link
Collaborator

performance.memory is a non-standard, deprecated API, at least according to MDN. performance.measureUserAgentSpecificMemory seems to be the more modern version, with an actual spec (although not actually standardised yet). Would adding (unstable) support for that instead be acceptable?

@emilk
Copy link
Author

emilk commented Mar 11, 2023

Yes, performance.measureUserAgentSpecificMemory sounds perfect!

@emilk emilk changed the title window.performance.memory performance.measureUserAgentSpecificMemory Mar 11, 2023
@emilk emilk changed the title performance.measureUserAgentSpecificMemory performance.measureUserAgentSpecificMemory Mar 11, 2023
Liamolucko added a commit to Liamolucko/wasm-bindgen that referenced this issue Mar 13, 2023
Fixes rustwasm#3159

This is a Chrome-only API for measuring the memory usage of JS/wasm. So, I've marked it as unstable.
alexcrichton pushed a commit that referenced this issue May 8, 2023
Fixes #3159

This is a Chrome-only API for measuring the memory usage of JS/wasm. So, I've marked it as unstable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants