Skip to content

Heap profiling

Simon Warta edited this page Feb 28, 2024 · 4 revisions

In order to detect memory leaks or excessive memory consumption, we can use DHAT for heap profiling. This 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. Go to repo root 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

Useful links

Clone this wiki locally