valgrind - victronenergy/venus GitHub Wiki

Note: available since Venus OS v3.70 as working ipk

Valgrind

What is it

Valgrind is a programming tool for memory debugging, memory leak detection, and profiling. Homepage Wikipedia

install required package

First make sure opkg is setup correctly. There after install valgrind (and a compiler for testing).

opkg install valgring packagegroup-core-buildessential

leak.c

#include <stdlib.h>

int main() {
	char *p = malloc(100);
	return 0;
}

gcc leak.c -o leak

How to use it

root@ekrano:~# valgrind ./leak
==14959== Memcheck, a memory error detector
==14959== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==14959== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==14959== Command: ./leak
==14959== 
==14959== 
==14959== HEAP SUMMARY:
==14959==     in use at exit: 100 bytes in 1 blocks
==14959==   total heap usage: 1 allocs, 0 frees, 100 bytes allocated
==14959== 
==14959== LEAK SUMMARY:
==14959==    definitely lost: 100 bytes in 1 blocks
==14959==    indirectly lost: 0 bytes in 0 blocks
==14959==      possibly lost: 0 bytes in 0 blocks
==14959==    still reachable: 0 bytes in 0 blocks
==14959==         suppressed: 0 bytes in 0 blocks
==14959== Rerun with --leak-check=full to see details of leaked memory
==14959== 
==14959== For lists of detected and suppressed errors, rerun with: -s
==14959== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Valgrind has a lot of options that can be set. Example:
valgrind -v --num-callers=50 --track-origins=yes --leak-check=full ./leak

plugins

Optional plugins are available as ipks, see for example

  • valgrind-cachegrind
  • valgrind-callgrind
  • valgrind-massif

Qt program

note: At the moment, September 2025, valgrind has problems correctly tracking Qt program

⚠️ **GitHub.com Fallback** ⚠️