Skip to content

Heap profiling

WARNING

This page needs review, because this procedure does not work anymore, see #2.

The DHAT tool can be used for heap profiling to detect memory leaks or excessive memory usage. This tool is currently set up in the cosmwasm-vm package. It was used to debug this memory usage bug in CosmWasm 1.3 and 1.4.

Getting started

  1. Navigate to the root directory of the cosmwasm repository and run:
    cargo run --features dhat-heap --example heap_profiling --release
  2. Open dhat-heap.json in DHAT Viewer.
  3. Enjoy

Reading the output

  • tgmax is the time of the highest memory usage
  • tend is the time of the process end

Customising

  • The --runtime argument allows for longer testing periods, e.g. for running tests for 2 minutes do
    cargo run --features dhat-heap --example heap_profiling --release -- --runtime 120
  • In fn contracts() you can change the contracts that are executed

References