Profiling
Heaptrack is a heap memory profiler for Linux, which can also be instrumented to run on OSX.
Being Linux only, some steps are necessary to ensure heaptrack can be used on OSx.
Pre requisites
Section titled “Pre requisites”Devcontainer is leveraged to have amaru run in a pre-configured linux environment. Then XQuartz is used to display graphics directly on OSx host.
First install XQuartz
brew install --cask xquartzthen run it open -a XQuartz and allow remote external connections in menu Settings/Security then restart.
Finally, from within XQuartz integrated terminal, run xhost +localhost. IMPORTANT this has to be done each time XQuartz is restarted.
Using VSCode
Section titled “Using VSCode”VSCode natively supports devcontainer so simply reopen your workspace in devcontainer. You will then get access to a regular VSCode instance as if it was running from within the docker instance.
Generate a heaptrack snapshot
Section titled “Generate a heaptrack snapshot”cargo build --profile profilingheaptrack ./target/profiling/amaru $YOUR_OPTIONSAnalyse heaptrack snapshot
Section titled “Analyse heaptrack snapshot”heaptrack_gui SNAPSHOT_FILEUsing another editor
Section titled “Using another editor”Use Dev Container CLI to automate interactions with the docker image:
devcontainer up --workspace-folder .devcontainer exec --workspace-folder . cargo build --profile profilingdevcontainer exec --workspace-folder . heaptrack ./target/profiling/amaru