This experimental tool intercepts allocations and deallocation and logs the events to the fuchsia tracing system with the category memory_trace.
--with-host //src/performance/memory/profile:fxt_to_pprof --with-base //bundles:toolspprof and gzip binaries are in the environment path.libmemory_trace.so (//src/performance/memory/profile:memory_trace).configs = [ "//src/performance/memory/profile:no-as-needed" ] to the rustc_binary.fuchsia.tracing.provider.Registry to the component.The dynamic library registers hooks the Fuchsia default allocator for c and rust programs.
The memory profile collection can be started and stopped with ffx tool, however an helper script is provided to automate the trace post processing.
Know that trace collection modes commes with limitations:
bash src/performance/memory/profile/profile_memory.sh
This tool does the following:
ffx trace start --buffering-mode circular --categories memory_profilefxt trace to pprof protocol buffer format with //src/performance/memory/profile:memory_tracepprofpprof and upload the profile to a server--with //src/performance/memory/profile/examplebash src/performance/memory/profile/profile_memory.shffx component create /core/session-manager/session:hello-memory-profiler fuchsia-pkg://fuchsia.com/hello-memory-profiler#meta/hello-memory-profiler.cm ffx component start /core/session-manager/session:hello-memory-profilerRun the test with fx set: --with //src/performance/memory/profile:tests
Then:
fx test //src/performance/memory/profile