Skip to content

Comment on Twenty years of Valgrind

Comments

Is Valgrind any use in Rust?

I work full-time with Rust, use it all the time to see how much memory is being allocated to the heap, make a change and then see if there's a difference, and also for cache misses:

valgrind target/debug/rustbinary

==10173== HEAP SUMMARY:

==10173== in use at exit: 854,740 bytes in 175 blocks

==10173== total heap usage: 2,046 allocs, 1,871 frees, 3,072,309 bytes allocated

==10173==

==10173== LEAK SUMMARY:

==10173== definitely lost: 0 bytes in 0 blocks

==10173== indirectly lost: 0 bytes in 0 blocks

==10173== possibly lost: 1,175 bytes in 21 blocks

==10173== still reachable: 853,565 bytes in 154 blocks

==10173== suppressed: 0 bytes in 0 blocks

==10173== Rerun with --leak-check=full to see details of leaked memory

valgrind --tool=cachegrind target/debug/rustbinary

==146711==

==146711== I refs: 1,054,791,445

==146711== I1 misses: 11,038,023

==146711== LLi misses: 62,896

==146711== I1 miss rate: 1.05%

==146711== LLi miss rate: 0.01%

==146711==

==146711== D refs: 793,113,817 (368,907,959 rd + 424,205,858 wr)

==146711== D1 misses: 757,883 ( 535,230 rd + 222,653 wr)

==146711== LLd misses: 119,285 ( 49,251 rd + 70,034 wr)

==146711== D1 miss rate: 0.1% ( 0.1% + 0.1% )

==146711== LLd miss rate: 0.0% ( 0.0% + 0.0% )

==146711==

==146711== LL refs: 11,795,906 ( 11,573,253 rd + 222,653 wr)

==146711== LL misses: 182,181 ( 112,147 rd + 70,034 wr)

==146711== LL miss rate: 0.0% ( 0.0% + 0.0% )

Not used it with Rust, but have used it with OCaml, Perl, Ruby, Tcl successfully. In managed languages it's mainly useful for detecting problems in C bindings rather than the language itself. Languages where it doesn't work well: Python and Golang.

Depends how much unsafe code blocks you make use of.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.