just notes

valgrind – an example

# code with memory leak ./memoryleak.cpp

#include <string>

struct MyStruct{
    std::string test;


int main(){

    MyStruct *n = new MyStruct;
    n->test = "dsalfkjsdlfkjsdlfkjasdlfkjsadflkjsad";

    return 0;
> sudo apt install valgrind
> g++ test.cpp -o memleak.out
> valgrind --leak-check=full --verbose --show-leak-kinds=all --track-origins=yes -s  ./memleak.out --log-file=./valgrin-out.txt

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.