You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memoryprofiler doesn't support multi-threaded application #18107
I was using memoryprofiler to monitor the memory usage of a multi-threaded application. But it looks like it doesn't support to record the malloc and free from a worker thread.
I thinks the problem is here(src/library_trace.js)
emscripten_trace_record_allocation: function(address, size) {
// This line: only the main thread has onMalloc callback
if (typeof Module['onMalloc'] == 'function') Module['onMalloc'](address, size);
if (EmscriptenTrace.postEnabled) {
var now = EmscriptenTrace.now();
EmscriptenTrace.post([EmscriptenTrace.EVENT_ALLOCATE,
now, address, size]);
}
},
One option here might be to add emscripten_trace_record_allocation__proxy: 'async' to library.js, which would send messages to the main thread. Does that work? If so a PR would be welcome.
@kripken Thank you for the advice.
I looked into the proxy module, it's not that straightforward. The emscripten_run_in_main_runtime_thread_js (library_pthread.c) function will call malloc and cause a infinite loop deadlock.
Activity
junyuecao commentedon Oct 28, 2022
I thinks the problem is here(src/library_trace.js)
kripken commentedon Nov 3, 2022
One option here might be to add
emscripten_trace_record_allocation__proxy: 'async'tolibrary.js, which would send messages to the main thread. Does that work? If so a PR would be welcome.junyuecao commentedon Nov 4, 2022
@kripken Thank you for the advice.
I looked into the proxy module, it's not that straightforward. The emscripten_run_in_main_runtime_thread_js (library_pthread.c) function will call malloc and cause a infinite loop deadlock.
I'll continue to try to find a way to fix it.
[memoryprofiler] Show allocations from threads (#26175)