Qt desktop application for running and analyzing Valgrind Massif heap memory profiling output.
- Select a
CorC++source file (.c or .cpp) to automatically compile it and analyze with Valgrind Massif - Select a compiled binary to analyze
- Run Valgrind's Massif tool with custom options
- Parse Massif output
- Provide memory usage analysis with function-level insights, including detection of heap growth and stabilization
- Generate suggestions based on customizable thresholds to help identify abnormal memory behavior
📘 For detailed instructions, see the Usage Guide.
- Qt Creator (6.0+)
- WSL (Windows Subsystem for Linux)
- Ubuntu distribution inside WSL
g++andgcccompilers installed inside WSL- Valgrind installed in WSL
Download and install from https://www.qt.io/download
✅ Recommended: Use MSVC or MinGW kits for Desktop development
Open PowerShell as Administrator and run:
wsl --installwsl -l -vThis will list all installed distros, for example:
NAME STATE VERSION
* Ubuntu-22.04 Running 2
Debian Stopped 2Then set Ubuntu as default:
wsl --set-default Ubuntu-22.04Open powershell and launch wsl
wslThen inside wsl run
sudo apt update
sudo apt install build-essentialThe build-essential package includes gcc, g++, and other tools required for compiling C/C++ programs.
Open powershell and launch wsl
wslThen inside wsl run
sudo apt update
sudo apt install valgrindVerify installation:
valgrind --version-
Open the project folder containing
CMakeLists.txtin Qt Creator -
Configure with a Desktop kit
-
Click the Run button
▶️
💡 Make sure your Valgrind-executed binaries are accessible from WSL paths if running through Windows UI.
The ./test/ directory contains several example C and C++ source files that you can use to test the application.
When you run these test files through the application, the generated massif.out.x files will be saved by default in the ./massif_files/ directory.
Alternatively, you can use the provided run_massif_on_tests.sh script to automatically compile and generate massif.out.x files in the ./massif_files/ directory, which you can then load and analyze within the application.
The run_massif_on_tests.sh helper script is optional and automates the process of compiling and running C and C++ tests with Valgrind's Massif tool to generate profiling data.
This script can be used as a faster way to generate Massif output files, but all the same functionality is available through the Qt application itself.
-
Searches for
.cand.cppfiles listed in thetest/directory. -
Compiles them using the appropriate compiler:
gccfor.cfilesg++for.cppfiles
-
Automatically creates the
massif_files/directory if it doesn't exist. -
Runs each compiled test through
valgrind --tool=massif. -
Saves the output as
massif.out.<n>files inside themassif_files/directory.
📂 Example file structure:
├── QT_Massif_App/
├── test/
│ ├── test1.c
│ ├── test2.c
│ └── test3.cpp
├── massif_files/
│ ├── massif.out.1
│ ├── massif.out.2
│ └── massif.out.3
└── run_massif_on_tests.sh
💡 This script is helpful for quickly generating Massif profiling data for test binaries outside the Qt application interface.
-
(Optional) Predefined Test Files:
- The script is currently hardcoded to run the following test files:
test1.c,test2.c,test3.cpp,test4.cpp,test5.cpp. - To add your own test files, simply edit the
TEST_FILESarray in the script. For example:
TEST_FILES=("test1.c" "test2.c" "test3.cpp" "my_new_test4.c")
- The script will automatically detect the correct compiler based on the file extension (
gccfor.candg++for.cpp).
Note: This step is optional. If you don't need to modify the test files, you can skip it and use the default ones.
- The script is currently hardcoded to run the following test files:
-
Open WSL Terminal
- Open PowerShell in the directory where this project is located, then start WSL by running:
wsl
Note: This will open a Linux terminal in the current project folder, so you can run the bash script properly.
-
Make sure
run_massif_on_tests.shis executable:chmod +x run_massif_on_tests.sh
-
Run the script:
./run_massif_on_tests.sh
-
If you get a '
cannot execute' error running the script in WSL, it’s likely due to Windows-style CRLF line endings To fix this, in WSL installdos2unixif you don’t have it:sudo apt update sudo apt install dos2unix
Then convert the script to Unix line endings
dos2unix run_massif_on_tests.sh
Then you can run the script again
./run_massif_on_tests.sh
-
The script will automatically compile and run each test, saving the profiling results in the massif_files/ directory.
- 🐧 Valgrind runs only on Linux systems. On Windows, it uses WSL to execute Linux binaries.