-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Strategy for Testing SharedArrayBuffer in Wasm for Memory Leak Detection #24245
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
Comments
You can use sanitizers to find memory leaks: https://emscripten.org/docs/debugging/Sanitizers.html#memory-leaks |
Thank you for your response. We tried the same approach on our side and were able to detect memory leaks using the em++ -fsanitize=address -sEXIT_RUNTIME leak.cpp command. However, when adding the -gsource-map option as shown in your example, we encountered the following error: leak.cpp
Without the -gsource-map flag, the leak detection still works, but the trace doesn’t show source-level details—making it harder to pinpoint the exact cause.
We also wanted to share some context on why we’re asking this: We are currently evaluating a migration of one of our desktop UI applications to WebAssembly to make it available in web browsers. As part of our QA validation, we found out that memory split-up provided by Chrome profiler tools is totally different from what we actually see the memory taken by the Chrome browser in Activity Monitor. We were able to find few discrepancies like WebGL taken care entirely by Browsers whose memory is out of application scope. Similarly, VMs can also have its own memory. We would like to understand what other factors we need to consider when we want to monitor memory as a whole. Should we consider both the data from Profiler tools inside the browser and the actual memory taken from the OS level? Any guidance would be helpful. ![]() |
Strange that example seem to work fine for me:
I guess something must be up with the loading of the source map in our browser environment? Do you see any log messages about that on startup? |
I'm working on a WebAssembly application compiled with Emscripten that makes use of SharedArrayBuffer for inter-thread communication via Web Workers. I’d like to understand the usual or recommended strategy followed in the Emscripten/WebAssembly ecosystem for testing and validating correct usage of SharedArrayBuffer, particularly with respect to identifying potential memory leaks.
Specifically:
The text was updated successfully, but these errors were encountered: